counting references to an instance
theller at python.net
Wed Feb 4 20:36:11 CET 2004
Brian <balex at sympatico.ca> writes:
> Is it possible to get an object to return the number of references there
> are to itself?
> class test(object):
> a = test()
> b = a
> # Should print "2", if I knew the name of the method.
> print a.refCount()
In Python debug builds, there's the sys.getrefcount() function.
More information about the Python-list