deepcopy in new-style classes

Discussion in 'Python' started by Donnal Walter, Jun 22, 2004.

  1. 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
     
    Donnal Walter, Jun 22, 2004
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dlo_olb
    Replies:
    2
    Views:
    2,554
    Fredrik Lundh
    Jun 25, 2003
  2. Max Derkachev
    Replies:
    4
    Views:
    892
    Jack Diederich
    May 5, 2005
  3. ankit
    Replies:
    1
    Views:
    492
    Alex Martelli
    Dec 22, 2005
  4. Isaac Rodriguez

    Are all classes new-style classes in 2.4+?

    Isaac Rodriguez, Dec 31, 2006, in forum: Python
    Replies:
    4
    Views:
    598
    Steven D'Aprano
    Dec 31, 2006
  5. Quek
    Replies:
    3
    Views:
    464
  6. Terry Reedy
    Replies:
    5
    Views:
    762
    Robert Kern
    Nov 30, 2010
  7. Ken Varn
    Replies:
    0
    Views:
    745
    Ken Varn
    Apr 26, 2004
  8. Replies:
    2
    Views:
    788
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...