OOP in python

Thomas Wouters thomas at xs4all.net
Wed Mar 12 10:17:38 EST 2003


On Wed, Mar 12, 2003 at 06:41:18AM -0800, Bob Roberts wrote:

> What exactly do you inherit from another class in python?  With no
> type checking in python, the type doesn't matter, and the __init__()
> function of the parent doesn't seem to be called (unless you
> explicitly call it yourself).  Does it inherit anything more than just
> the member functions?

There isn't anything besides methods attributes (member functions and class
data.) Python objects define their behaviour almost exclusivly in terms of
'magic' methods, so there is little else that needs to be inherited.

Note that while type-checking is not builtin, and generally frowned upon, it
is possible to do class-based typechecking using the 'isinstance' and
'issubclass' functions. Instances of a subclass (at whatever level) of class
'Spam' are also an instance of class Spam as far as 'isinstance' is
concerned.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!





More information about the Python-list mailing list