faqts : Computers : Programming : Languages : Python : Language and Syntax : Classes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 12 people (92%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Can I get the variable name of an object instance?

Mar 1st, 2000 21:50
Nathan Wallace, Fredrik Lundh


Sorry, you can't do that.

Names are just names, not identities.  Any object can have lots of
different names, or none at all.

an example:

    clown = Hello(1)
    bobo = clown
    # here, bobo and clown both point to
    # the same instance
    del clown
    # now, only bobo points to that instance
    mylist = [bobo]
    del bobo
    # and here, nobody points directly to the
    # instance.

If you want to get the name of the class for an object instance, see
here:

  http://www.faqts.com/knowledge-base/view.phtml/aid/1328/fid/242