object query assigned variable name?
sion at viridian.paintbox
Tue May 5 10:43:07 EDT 2009
John O'Hagan <research at johnohagan.com> wrote:
>I can see that it's tantalizing, though, because _somebody_ must know about
>the assignment; after all, we just executed it!
Except we haven't, if we're talking about reporting from the
>>> class Brian:
... def __init__(self):
... print "I'm Brian!"
>>> l = 
>>> l = Brian()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list assignment index out of range
(Yeah, I know that's a setitem call not an assignment. Point stands.
It also demonstrates why the whole idea of "what name is a newly-
created object assigned to" is broken.)
More information about the Python-list