refcount

S

Simon Pickles

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

Thanks

Simon
 
D

Duncan Booth

Simon Pickles said:
Is is possible to access the refcount for an object? 6

Ideally, I am looking to see if I have a refcount of 1 before calling del

That's a pointless exercise: you probably don't understand what del does.

All that del does is remove one reference from an object, either by
removing a name from the namespace, or by removing a reference from
something like a list. 'del x' does NOT destroy the object referenced by x,
unless it happens that there are no other references to the object.

Also note that the only time you will see a reference count of 1 is on an
object which you cannot otherwise access (the only reference is being used
for the call to getrefcount()):
2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top