refcount

Mel mwilson at the-wire.com
Tue Jan 29 11:30:04 EST 2008


Benjamin wrote:
> On Jan 29, 5:46 am, Christian Heimes <li... at cheimes.de> wrote:
>> Simon Pickles wrote:
>>> Hi,
>>> Is is possible to access the refcount for an object?
>>> Ideally, I am looking to see if I have a refcount of 1 before calling del
>> Help on built-in function getrefcount in module sys:
>>
>> getrefcount(...)
>>     getrefcount(object) -> integer
>>
>> Return the reference count of object.  The count returned is generally
>> one higher than you might expect, because it includes the (temporary)
>> reference as an argument to getrefcount().
> Are there any cases when it wouldn't?

Well, as long as the object is named "object" in sys.getrefcount's 
namespace, there's at least that one reference to it...

	Mel.



More information about the Python-list mailing list