durusmail: durus-users: Durus Change Preview
Durus Change Preview
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-31
2006-10-31
Durus Change Preview
Mike Orr
2006-10-25
On 10/25/06, David Binger  wrote:
>
> On Oct 25, 2006, at 3:14 PM, Mike Orr wrote:
>
> > ...__getstate__ exists in Python to support pickling and the copy
> > module. No other Python package I know of uses .__getstate__ as a
> > substitute for .__dict__ or vars().  The logical alternative is:
> >    dict((x, getattr(obj, x)) for x in obj.__slots__)
> > though I suppose we can mention .__getstate__ as an alternative that
> > happens to work.
>
> No.
> This does not work unless all of the data slots are declared on this
> class.
> They may also be named on superclasses.

That's an interesting point.  I was going to say that the same problem
happens with .__dict__ and vars(): they only pick up instance
attributes and not superclass attributes.  But if the superclass has
slots, suddenly you have instance attributes that aren't stored in the
instance per se, so they're in between traditional instance attributes
and class attributes.

--
Mike Orr 
reply