Weakrefs to classes that derive from str

Peter Hansen peter at engcorp.com
Wed Mar 30 15:17:40 CEST 2005


Steven Bethard wrote:
> Ron Garret wrote:
>> None of the native types (int, float, list, tuple, etc.) can have weak 
>> references, but wrapping them in a class is supposed to get around 
>> that.  And it does -- for all classes except str.
> 
> Interesting.  Is the wrapping thing documented somewhere?  I didn't see 
> it in the documentation for weakref.ref (though I have been known to be 
> blind occasionally) ;)

I believe it's here: http://docs.python.org/lib/module-weakref.html
if you search for the string "Not all" and read the next two
paragraphs.

On the other hand, it says (there) only that "several builtin
types such as list and dict ... can add support through
subclassing", and does not say anything about int, str, etc...

-Peter



More information about the Python-list mailing list