Re: Printing the name of a variable

2010-09-10 Thread Simon Brunning
On 9 September 2010 20:43, Stephen Boulet wrote: > Does an arbitrary variable carry an attribute describing the text in > its name? I'm looking for something along the lines of: > > x = 10 > print x.name 'x' -- Ch

Re: Printing the name of a variable

2010-09-10 Thread Jonathan Hartley
On Sep 9, 9:11 pm, Albert Hopkins wrote: > On Thu, 2010-09-09 at 12:43 -0700, Stephen Boulet wrote: > > Does an arbitrary variable carry an attribute describing the text in > > its name? I'm looking for something along the lines of: > > > x = 10 > > print x.name > > >>> 'x' > > > Perhaps the x.__g

Re: Printing the name of a variable

2010-09-10 Thread Paul Rudin
Stephen Boulet writes: > Does an arbitrary variable carry an attribute describing the text in > its name? I'm looking for something along the lines of: > > x = 10 > print x.name 'x' > > Perhaps the x.__getattribute__ method? Thanks. The first thing is... what is your use case for this? I'd

Re: Printing the name of a variable

2010-09-09 Thread Mel
Stephen Boulet wrote: > Does an arbitrary variable carry an attribute describing the text in > its name? I'm looking for something along the lines of: > > x = 10 > print x.name 'x' > > Perhaps the x.__getattribute__ method? Thanks. Hmm. "Recent scholarship suggests that the Iliad and the

Re: Printing the name of a variable

2010-09-09 Thread Ben Finney
Albert Hopkins writes: > On Thu, 2010-09-09 at 12:43 -0700, Stephen Boulet wrote: > > Does an arbitrary variable carry an attribute describing the text in > > its name? > > Variables are not objects and so they have no attributes. Another way of thinking about is that there are no variables, onl

Re: Printing the name of a variable

2010-09-09 Thread Terry Reedy
On 9/9/2010 3:43 PM, Stephen Boulet wrote: In Python, 'variable' is a synonym for name and identifier,' An object can have 0 to many names attached to it. An object can also be a member of 0 to many collections. Modules, classes, and functions have 'definition name' strings attached to them

Re: Printing the name of a variable

2010-09-09 Thread Albert Hopkins
On Thu, 2010-09-09 at 12:43 -0700, Stephen Boulet wrote: > Does an arbitrary variable carry an attribute describing the text in > its name? I'm looking for something along the lines of: > > x = 10 > print x.name > >>> 'x' > > Perhaps the x.__getattribute__ method? Thanks. Variables are not objec

Printing the name of a variable

2010-09-09 Thread Stephen Boulet
Does an arbitrary variable carry an attribute describing the text in its name? I'm looking for something along the lines of: x = 10 print x.name >>> 'x' Perhaps the x.__getattribute__ method? Thanks. -- http://mail.python.org/mailman/listinfo/python-list