On this page
weakref.proxy
Prev: weakref.getweakrefs | Up: weakref | Next: weakref.ProxyType
Rel: weakref.CallableProxyType, weakref.finalize, weakref.getweakrefcount, weakref.getweakrefs
Ref: docs.python.org — weakref.proxy
Tags: #public #python3 #stdlib #weakref
Import
import weakref
from weakref import proxy
Signature & Overview
weakref.proxy(object, callback=None, /)
Create a proxy object that weakly references 'object'.
Usage
import weakref
class Box:
val = 99
b = Box()
p = weakref.proxy(b)
assert p.val == 99
Gotchas
- Raises
ReferenceErroronce the referent dies (unlikeweakref.ref()which returnsNone).
REPL Inspect
from weakref import proxy
help(proxy)
Linked from
Related notes
- tuts/python3/stdlib_module/weakref/CallableProxyType Linked here; links to this page; shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/finalize Linked here; links to this page; shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/getweakrefcount Linked here; links to this page; shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/getweakrefs Linked here; links to this page; shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/ProxyType Linked here; links to this page; shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/weakref/ref shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/ReferenceType shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/WeakKeyDictionary shared tags: #stdlib, #weakref
- tuts/python3/stdlib_module/weakref/WeakMethod shared tags: #stdlib, #weakref