Python as an Object Oriented Programming Language

Mike Meyer mwm at mired.org
Tue Dec 17 16:49:12 EST 2002


mis6 at pitt.edu (Michele Simionato) writes:

> 1. Unifying types and classes in Python 2.2

Skipped, because I'd like to know the answer as well.

> 2. What does it mean "pure" Object Oriented language ?
> I see SmallTalk and more recently Ruby make a great deal to be "pure".
> But I have no clue what this does mean in concrete terms. I have seen
> people say "the language is pure when everything is an object", but
> it seems to me that in Python everything is an object too:

I think there are two different meanings of the word object here. What
they really mean is that all variables are either method local or
attributes of an object, and all code is in methods. If you want to
get really picky, you can claim that Python is pure because functions
are static methods of modules, and global variables are attributes of
modules, and module is a built-in object type with a really funny
syntax.

> I don't see if Python misses something to be considered a "pure" Object 
> Oriented language. Notice that I am not a purist, I simply would like to
> understand the concept.

You can write programs in Python as if it were a "pure" OO
language. The only code that should be written outside of any class
looks like:

        if __name__ == "__main__":
            intitial_class().initial_method()


> 3. Multiple inheritance.
> I have read this citation by Zack Urlocker "Multiple Inheritance is the goto of 
> the 90's" and various recommendation against it. On top of that, various 
> languages forbid it by design, because it is a Bad Thing. Nevertheless, it 
> doesn't seem so evil to me in Python, I also have seen a paper by Chuck Esterbrook 
> about Multiple Inheritance and mixins as a very useful technique. I think the 
> original quotation referred to C++ where multiple inheritance is such a mess.
> OTOH, it doesn't seems very difficult or very dangerous in Python once you
> have understood the Method Resolution Order. Am I correct ? What are the general 
> guidelines of the Python community about multiple inheritance ?

Mutliple inheritance is a good and useful thing. Languages that
implement it poorly have confused the issue, and some smart
people. Python has a useful implementation, but not a great one.

I recommend you find a read "Object Oriented Software Construction" by
Betrand Meyer. He deals with the issue of multiple inheritance quite
well there. He also uses a "pure" OO language to discuss the issues,
so you can get a feel for what that is like. Finally, it's an
excellent book on writing OO software.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list