Author stutzbach
Recipients stutzbach
Date 2009-10-19.21:48:06
SpamBayes Score 3.01133e-07
Marked as misclassified No
Message-id <1255988888.99.0.764366839405.issue7170@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for weakref contains the following example:

http://docs.python.org/3.1/library/weakref.html

----------------------------------------------
Several built-in types such as list and dict do not directly support
weak references but can add support through subclassing:

class Dict(dict):
    pass

obj = Dict(red=1, green=2, blue=3)   # this object is weak referenceable
----------------------------------------------

While this works fine for list and dict, it does not work for tuple or int:

>>> class Tuple(tuple):
...     pass
...
>>> obj = Tuple()
>>> weakref.ref(obj)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot create weak reference to 'Tuple' object

I've tried it in Python 2.5, 2.6, and 3.1.
History
Date User Action Args
2009-10-19 21:48:09stutzbachsetrecipients: + stutzbach
2009-10-19 21:48:08stutzbachsetmessageid: <1255988888.99.0.764366839405.issue7170@psf.upfronthosting.co.za>
2009-10-19 21:48:07stutzbachlinkissue7170 messages
2009-10-19 21:48:06stutzbachcreate