[Tutor] How to get variable name from its id()
Gerrit Holl
gerrit at nl.linux.org
Fri Feb 6 09:10:23 EST 2004
<quote name="orbitz at ezabel.com" date="1076053784" email="orbitz at ezabel.com">
> I don't quite follow what you mean here. If you just do ID = Name, then ID and
> Name will point to the same object. Strings are immutable though so if you
> change one it wont' be reflected in the other. For example:
> >>> Name = 'blah'
> >>> ID = Name
> >>> ID is Name
> True
> >>> ID = 'zing'
> >>> ID is Name
> False
I think he means:
>>> name = 'blah'
>>> id(name)
-1085830240
...and then get 'blah' back from the ID.
I don't think it's possible. I'm not sure what deep ways into the
interpreter Python offers, however, so I may be wrong.
Weird, however, a negative ID..
Gerrit.
--
Mozilla _is_ the web: it grows faster than you can download it.
1011001 1101111 1110101 1110010 1110011 0101100
1000111 1100101 1110010 1110010 1101001 1110100
More information about the Tutor
mailing list