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. Advertising

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. Max Derkachev
    Replies:
    4
    Views:
    689
    Jack Diederich
    May 5, 2005
  2. ankit
    Replies:
    1
    Views:
    361
    Alex Martelli
    Dec 22, 2005
  3. Isaac Rodriguez

    Are all classes new-style classes in 2.4+?

    Isaac Rodriguez, Dec 31, 2006, in forum: Python
    Replies:
    4
    Views:
    398
    Steven D'Aprano
    Dec 31, 2006
  4. Quek
    Replies:
    3
    Views:
    347
  5. Ken Varn
    Replies:
    0
    Views:
    506
    Ken Varn
    Apr 26, 2004
Loading...

Share This Page