Python as an Object Oriented Programming Language

Steve Holden sholden at holdenweb.com
Tue Dec 17 15:35:55 EST 2002


"Michele Simionato" <mis6 at pitt.edu> wrote in message
news:2259b0e2.0212171221.7763649e at posting.google.com...
> 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 ?
>
What's the type of an instance of a classic class? What's the type of a type
instance? That's the principal difference from the naiive user's PoV.

> 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.
>
Puse in this context means that every type inheritds from some archetypical
base type. Hence 2.2.2, even, is not "pure", while SmallTalk (where integer
is a subclass of object) is.

> 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,
>
Use it carefullY!

REGARDS
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Bring your musical instrument to PyCon!    http://www.python.org/pycon/
-----------------------------------------------------------------------
/






More information about the Python-list mailing list