[Python-ideas] Put default setstate and getstate on object for use in coöperative inheritance.

Steven D'Aprano steve at pearwood.info
Sat Jun 7 07:14:57 CEST 2014


On Fri, Jun 06, 2014 at 06:53:30PM -0700, Neil Girdhar wrote:
> 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:

I'm afraid you're going to need to explain in more detail what you're 
talking about. Even a link to a discussion elsewhere. I've used 
cooperative inheritance without needing to write a getstate or setstate 
method, so I have no idea why you think these are important enough to go 
into the base object. I presume you're not talking about serialization 
formats? That's where I would normally expect to find a getstate and 
setstate.

It might also help if you can do a survey of other languages, like Java 
and Ruby, and tell us if they have such methods in the base object.


-- 
Steven


More information about the Python-ideas mailing list