June 7, 2014
1:53 a.m.
When implementing getstate in coöoerative inheritance, the typical thing to do is to call super to get dictionary and add the appropriate entries. Setstate is similar: you extract what you need out of the dictionary and call super with the remaining entries. Unfortunately, object does not have a default implementation, so you need a base class like so: class DefaultSetstateAndGetstate: """ Define default getstate and setstate for use in coöperative inheritance. """ def __getstate__(self): return self.__dict__.copy() def __setstate__(self, state): self.__dict__.update(state) I suggest that this be added to object. Best, Neil