counting references to an instance
Aahz
aahz at pythoncraft.com
Wed Feb 4 14:57:59 EST 2004
More information about the Python-list mailing list
Wed Feb 4 14:57:59 EST 2004
- Previous message (by thread): PEP 327: Decimal Data Type
- Next message (by thread): counting references to an instance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <pan.2004.02.04.18.55.02.385092.6672 at sympatico.ca>, Brian <balex at sympatico.ca> wrote: > >Is it possible to get an object to return the number of references there >are to itself? > >Ex: > >class test(object): > pass > >a = test() >b = a > ># Should print "2", if I knew the name of the method. >print a.refCount() sys.getrefcount(a) will do the trick -- but it will print 3. Can you figure out why? -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death." --GvR
- Previous message (by thread): PEP 327: Decimal Data Type
- Next message (by thread): counting references to an instance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list