[Tutor] How to get variable name from its id()

orbitz at ezabel.com orbitz at ezabel.com
Fri Feb 6 08:49:44 EST 2004

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
>>> ID = 'zing'
>>> ID is Name

I hope this answers your question.

On Fri, 6 Feb 2004 02:07:57 -0500
"Isr Gish" <isrgish at fusemail.com> wrote:

> Is it possible to get the variable name or its contents if we know its I?d.
> Name = 'Isr Gish'
> ID = id(Name)
> Now use I?D to either find the variable name (Name), or get the contents of
> Name.
> If someone can point me where to find this info. It would be greatly
> appreciated.
> All the best
> Isr
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list