On Thu, 31 Mar 2005 03:33:10 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: > On 31 Mar 2005 08:13:30 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > > > But surely if you create an integer object and assign it a value, e.g. > > > a = 3, > > > why shouldn't Python be able to tell you something like the following: > > > name(a) >>> 'a' > > > ? > > > > But why should it return 'a' and not one of these? > > Because the python interpreter certainly knows the name of all the > variables used in a python program. So, a name() function as discussed > here should return the name of the exact variable passed in as input, > not any variable which refers to the value 3 (which is of course > constant). We're imagining a new function, not discussing yours.
Reason #312 not to post at 3:30 AM: Ok, the variable name is evaluated before being passed to the function. Thus, it would require some pretty heavy interpreter trickery to implement. I take back what I said. Humbly, Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list