Python as an Object Oriented Programming Language
Michele Simionato
mis6 at pitt.edu
Tue Dec 17 15:21:43 EST 2002
I have a few general questions on Python as an Object Oriented Programming
language.
---
Disclaimer: possibly some of these questions are naive, since I am
pretty new to the Object Oriented world, but willing to learn ;-)
1. Unifying types and classes in Python 2.2
That (in)famous paper of Guido starts with the sentence:
Python 2.2 introduces the first phase of "type/class unification". This
is a series of changes to Python intended to remove most of the
differences between built-in types and user-defined classes.
I wonder what would be the second phase. It seems to me that classes and
types are already unified !
>>> examples=[1,1.2,'hello',[],{},(),object(),type('Class',(),{}),type]
>>> for e in examples: assert type(e)==e.__class__
On the other hand classic classes have not __class__ attribute and
therefore I interpret the previous sentence as meaning that the second phase
will be complete when classic classes will go away, since according to Guido:
Classic classes are still a special category in Python 2.2. Eventually they
will be totally unified with types, but because of additional backwards
incompatibilities, this will be done after 2.2 is released (maybe not before
Python 3.0).
Am I correct or still there are subtle difference between classes and types
even in new style classes ?
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:
>>> for e in examples: assert isinstance(e,object)
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.
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 ?
That's all folks, TIA for your replies,
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
More information about the Python-list
mailing list