deepcopy in new-style classes

Donnal Walter donnal at donnal.net
Tue Jun 22 14:02:27 EDT 2004


I have defined a set of new-style classes that override __getstate__() 
and __setstate__(). For these classes, copy.deepcopy works fine as long 
as __getstate__() returns a value other than None, False, [], {}, '' and 
0. The 2.3 documentation says: """For new-style classes, if 
__getstate__() returns a false value, the __setstate__() method will not 
be called. """ Why is this the case? And is there someway to get around 
this, i.e. force __setstate__() to be called anyway?

Donnal Walter
Arkansas Children's Hospital






More information about the Python-list mailing list