summaryrefslogtreecommitdiffstats
path: root/Doc/library/weakref.rst
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2013-04-13 14:45:44 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2013-04-13 14:45:44 (GMT)
commit556e94b8fe068d1d58064fe84467e0620b87f9ed (patch)
tree8d6d21319dd056b30cb089d645ba8a0f729c39f7 /Doc/library/weakref.rst
parent548677bb8ce759395e2512420c03ccb184a77bf5 (diff)
downloadcpython-556e94b8fe068d1d58064fe84467e0620b87f9ed.zip
cpython-556e94b8fe068d1d58064fe84467e0620b87f9ed.tar.gz
cpython-556e94b8fe068d1d58064fe84467e0620b87f9ed.tar.bz2
Issue #17643: Add __callback__ attribute to weakref.ref.
Diffstat (limited to 'Doc/library/weakref.rst')
-rw-r--r--Doc/library/weakref.rst14
1 files changed, 12 insertions, 2 deletions
diff --git a/Doc/library/weakref.rst b/Doc/library/weakref.rst
index 1bf6b58..78ff21d0 100644
--- a/Doc/library/weakref.rst
+++ b/Doc/library/weakref.rst
@@ -111,6 +111,15 @@ Extension types can easily be made to support weak references; see
This is a subclassable type rather than a factory function.
+ .. attribute:: __callback__
+
+ This read-only attribute returns the callback currently associated to the
+ weakref. If there is no callback or if the referent of the weakref is
+ no longer alive then this attribute will have value ``None``.
+
+ .. versionadded:: 3.4
+ Added the :attr:`__callback__` attribute.
+
.. function:: proxy(object[, callback])
@@ -261,8 +270,9 @@ These method have the same issues as the and :meth:`keyrefs` method of
Weak Reference Objects
----------------------
-Weak reference objects have no attributes or methods, but do allow the referent
-to be obtained, if it still exists, by calling it:
+Weak reference objects have no methods and no attributes besides
+:attr:`ref.__callback__`. A weak reference object allows the referent to be
+obtained, if it still exists, by calling it:
>>> import weakref
>>> class Object: