On Tue, May 8, 2012 at 1:19 PM, Russell E. Owen <[email protected]> wrote: > In article <[email protected]>, > "Russell E. Owen" <[email protected]> wrote: > >> What is the sequence of calls when unpickling a class with __setstate__?
I believe it just calls object.__new__ followed by yourclass.__setstate__. So at the point __setstate__ is called, you have a pristine instance of whatever class you're unpickling. > The following seems to work, but I don't know why: > def __getstate__(self): > ...return the argument dict needed for __init__ > > def __setstate__(self, argdict): > self.__init__(**argdict) That seems like it should be fine as long as all your initialization code is in __init__ and not in __new__. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
