Weakrefs to classes that derive from str
Ron Garret
rNOSPAMon at flownet.com
Tue Mar 29 21:15:18 EST 2005
Why doesn't this work?
>>> from weakref import ref
>>> class C(str): pass
...
>>> ref(C())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: cannot create weak reference to 'C' object
>>>
Note that this does work:
>>> class D(int): pass
...
>>> ref(D())
<weakref at 0x53e10; dead>
>>>
Likewise for floats, lists, etc. Everything but strs.
rg
More information about the Python-list
mailing list