subclassing versus object redefinition

wheres pythonmonks wherespythonmonks at gmail.com
Tue Aug 3 08:46:16 EDT 2010


Hi!

I have a class (supposed to be an abstract base class):
In python (as opposed to static languages like C++) I don't seed to
subclass the base class, but instead I can simply override the
behavior of stub methods and values.
Is there a preference between between subclassing (C++ approach) and
overriding methods/data in an instance?  From a design perspective?
I think I prefer the override/redefine approach because it result in a
thinner class hierarchy.

It seems like inheriting an ABC is needed only when I must share
instances (between multiple parts of the code, or if the subclass is
instantiated in different places...)

Thoughts?

W



More information about the Python-list mailing list