Feasible in Python ? list of object , with two exeptional objects
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Dec 28 05:14:27 EST 2006
In <8vv6p29lqjl24bkcge3iv66vflvt683akc at 4ax.com>, Osiris wrote:
> Would I put all the stuff that is the same in both classes in the base
> class and only the differing stuff in the subclasses ?
Yes that's the intent of base/sub class relationships. Baseclasses
contain the behavior common to all their subclasses and subclasses
implement just the different or additional behavior.
> Could I move the normal length method to the superclass, and override
> it in the special class, like this:
Yes that can be done and makes perfectly sense if the `length()` in the
baseclass is the "normal" behavior and that baseclass can be instantiated
and used directly.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list