weakref.proxy()
weakref.proxy() is a Python function in the Weakref Module category. Creates a weak reference proxy that acts like the original object. The syntax is weakref.proxy(object, callback=None). Returns: Proxy object. A typical example: p = weakref.proxy(obj)
p.method() # Same as obj.method(). A close sibling is weakref.ref(), which creates a weak reference object. Call .deref() to get the object or None if collected. A close sibling is weakref.WeakValueDictionary(), which a dictionary that holds weak references to its values. A close sibling is weakref.WeakKeyDictionary(), which a dictionary that holds weak references to its keys. A close sibling is weakref.WeakSet(), which a set that holds weak references to its elements. More about this category: Weak references — ref, proxy, WeakValueDictionary, WeakSet. Related Weakref Module entries: weakref.ref(), weakref.WeakValueDictionary(), weakref.WeakKeyDictionary(), weakref.WeakSet(), weakref.finalize(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.