In article <pa*********************************@sympatico.ca> ,
Brian <ba***@sympatico.ca> wrote:
On Wed, 04 Feb 2004 14:57:59 -0500, Aahz wrote: In article <pa*********************************@sympatico.ca> , Brian
<ba***@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?
Does the instance of test contain a reference to itself?
Nope. Robert Brewer's response explained it.
--
Aahz (aa**@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