Thanks a lot folks for all the help. Its a lot clearer now.

If I could summarise my original misunderstanding about inheritance:

I belived that a sub class inherited a *specific instance* of the super
class.

This is clearly not right - the misunderstanding arose as I was
instantiating the super class from within the base class. As people
have pointed out it seems strange to instantiate an 'animal' and then
only later decide that it is a 'fish' or a 'bird'. Obviously my code is
an analogy to the problem I'm tackling. What I'm doing is a bit more
abstract: I'm instantiating a 'world' (as a super class) and then
various 'worldviews' as sub-classes. The 'worldviews' must know about
various aspects of the 'world' from which they are instantiated to be
able to do what they need to do (as the 'bird' needs to know about
'weight' and 'colour' to be able to describe itself).

Passing these aspects forward to the constructor of the sub class is
the solution I've implemented and it works and looks sensible.

Thanks again to all,


 Lorcan.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to