Eugene Toder added the comment:

Yes, this is similar to my second approach. (You need to copy via __reduce__, 
because __copy__ my have been overriden to return self.)

The general problem with it, is that if a subclass is designed to be immutable 
(probably a common case here), it may not handle changing of its attributes 
well. Attributes will be readonly, so you can't support 
replace(derived_attr=newval). And while you can change base class' attributes 
under the covers, doing so may break subclass invariants. E.g. it may have 
cached hashcode or another property derived from other attributes.

There's also a smaller problem of figuring attribute names for positional 
arguments of replace() to support derived attributes.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20371>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to