deepcopy in new-style classes

D

Donnal Walter

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top