initializing mutable class attributes

Anthony Baxter anthonybaxter at gmail.com
Wed Sep 1 11:14:56 EDT 2004


On Wed, 01 Sep 2004 14:54:06 GMT, Dan Perl <dperl at rogers.com> wrote:
> Not in Python.  A user of my library has to invoke the parent's class
> __init__ in their own __init__.  What happens if, in a future release, I get
> rid of the __init__ in the parent class?  Or the other way around.  An early
> release does not have a parent __init__, the users don't invoke it because
> they can't, and then, in a future release, I add the parent __init__ because
> I added some attributes.  It breaks all the users' code.  This is poor
> encapsulation.

Use 'super()', in that case.

http://www.python.org/dev/doc/devel/lib/built-in-funcs.html#l2h-70



More information about the Python-list mailing list