Message94260
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. |
|
| Date |
User |
Action |
Args |
| 2009-10-19 21:48:09 | stutzbach | set | recipients:
+ stutzbach |
| 2009-10-19 21:48:08 | stutzbach | set | messageid: <1255988888.99.0.764366839405.issue7170@psf.upfronthosting.co.za> |
| 2009-10-19 21:48:07 | stutzbach | link | issue7170 messages |
| 2009-10-19 21:48:06 | stutzbach | create | |
|