A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026111.html below:

[Python-Dev] weakref (or doc) bug?

[Python-Dev] weakref (or doc) bug? [Python-Dev] weakref (or doc) bug?David Abrahams David Abrahams" <david.abrahams@rcn.com
Tue, 2 Jul 2002 14:09:42 -0400
>>> help(weakref.ref)
Help on built-in function ref:

ref(...)
    new(object[, callback]) -- create a weak reference to 'object';
    when 'object' is finalized, 'callback' will be called and passed
    a reference to 'object'.
    ^^^^^^^^^^^^^^^^^^^^^^^

This appears to be a lie, or at least misleadingly phrased, in Python
2.2.1:

>>> class Z: pass
...
>>> def dying(x): print x, 'is dying'
...
>>> z = Z()
>>> r = weakref.ref(z, dying)
>>> z = 1
<weakref at 9826f8; dead> is dying

It appears that it's a reference to the weakref object that's passed, not
the dying object itself.

What's the intention?

TIA,
Dave

+---------------------------------------------------------------+
                  David Abrahams
      C++ Booster (http://www.boost.org)               O__  ==
      Pythonista (http://www.python.org)              c/ /'_ ==
  resume: http://users.rcn.com/abrahams/resume.html  (*) \(*) ==
          email: david.abrahams@rcn.com
+---------------------------------------------------------------+





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4