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/2004-May/045006.html below:

[Python-Dev] Why aren't more things weak referencable

[Python-Dev] Why aren't more things weak referencable [Python-Dev] Why aren't more things weak referencableRaymond Hettinger raymond.hettinger at verizon.net
Sat May 29 13:06:31 EDT 2004
Instances of classes inheriting from str, tuple, etc cannot be weakly
referenced.  Does anyone know the reason for this?
 
>>> from weakref import proxy
>>> class Object(object):
            pass
 
>>> x = Object()
>>> y = proxy(x)    # no problem here
>>> class Str(str):
            pass
 
>>> x = Str()
>>> y = proxy(x)   # but why won't this work?
 
Traceback (most recent call last):
  File "<pyshell#9>", line 1, in -toplevel-
    y = proxy(x)
TypeError: cannot create weak reference to 'Str' object
 
 
Weak referencing would be much more useful to me if it included strings,
tuples, and such.  Right now, my awkward workaround is substituting
UserString or some other wrapper class replacing inheritance with
delegation.
 
 
Raymond Hettinger
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20040529/1ab23f85/attachment.html
More information about the Python-Dev mailing list

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