Method to know if object support being weakreferenced ?

Gregory Ewing greg.ewing at canterbury.ac.nz
Tue Dec 13 01:21:45 EST 2016


Matthias Bussonnier wrote:
> I search for a method
> capable of telling me whether an object can be weakreferenced.

Objects that can be weakly referenced have a __weakref__ attribute.
So you could use hasattr(obj, '__weakref__').

-- 
Greg


More information about the Python-list mailing list