[Tutor] OOD - Another class question
Steve Willoughby
steve at alchemy.com
Mon Mar 1 00:36:38 CET 2010
On Sun, Feb 28, 2010 at 06:24:09PM -0500, James Reynolds wrote:
> I have another question related to OOD. What I have is a module with one
> parent class and two child classes. Some stuff is done to the object that is
> passed to the function in one of the child classes and this then calls a
> function from the global class passing local variables (from the child
> class).
I think you're confusing containers with inheritance.
> class MountainBuilder(object):
> def __init__(self, mountain):
> self.mountain = mountain
> self.mountain_func <--- what's this?
> self.pinetree_func <--- what's this?
>
> class HillBuilder(MountainBuilder):
> def __init__(self, mountain):
> OptionLoad.__init__(self, mountain)
> self.MountainBuilder.mountain_func
There is no MountainBuilder attribute in HillBuilder. Rather,
HillBuilder is a refined type of a MountainBuilder, and inherits
everything MountainBuilders have, plus what you change or add
to that base in HillBuilder.
You're treating it like it's a separate class which contains
a MountainBuilder object inside it as an attribute.
More information about the Tutor
mailing list