Acquiring a regular link from weakref proxy in python

Is there a way to get the correct link for an object for which I am getting a weakref proxy?

I looked through the weakref module documentation and did not get a response there, or manually popped the weakproxy object.

+4
source share
1 answer

You can get the referent from the weakref object by calling it:

obj = ref()

From weakrefdocs :

Weak reference objects do not have attributes or methods, but allow the referent to be obtained if it still exists by calling it. If the referent no longer exists, a call to the reference object returns None.

-, - weakref.

+1

All Articles