Extending classes __init__behavior for newbies

Michael Sparks sparks.m at gmail.com
Mon Feb 14 20:45:10 CET 2011

On Feb 14, 7:15 pm, rantingrick <rantingr... at gmail.com> wrote:
> On Feb 14, 11:55 am, Michael Sparks <spark... at gmail.com> wrote:
> > It can be broken if someone tries to use the class as is - that is
> > treating the class as a model - to drive a display of the ship. If
> > it was written using super() then that wouldn't be a problem.
> > For example, I could write a display mixin that I'd like to use like
> > this:
> [snip: miles of code not formatted for 79 chars!]

Core code recopied into a pastebin instead, if that's your only
 * http://pastebin.com/nuaafqSE

I hardly call 87 lines of code "miles of code" though myself.  I call
it a relatively trivial example aimed at showing the benefit of using
super() in your code rather than hard coding brittle fragility into
your code.

> That was a nice long winded example of how to break code by using it
> in an improper manner.

No, it was a thought out example of how writing code slightly
differently from how you do now can result in something more
practical, reusable, extendable, and maintainable. I was hoping to
educate you as to why one approach *might* be considered better than

Deriding is as you do completely misses the point, sadly.


More information about the Python-list mailing list