[Tutor] no. of references

Dave Angel davea at ieee.org
Tue Jun 8 14:48:48 CEST 2010


Payal wrote:
> Hi,
> If I have a list (or a dict), is there any way of knowing how many other
> variables are referencing the same object?
>
> With warm regards,
> -Payal
>   
Depends on what you mean by variables.

Try   sys.getrefcount(mylist)


Naturally, the count will be one higher than you expect.  And you should 
only use this for debugging purposes.

DaveA



More information about the Tutor mailing list