IsPython really O-O?

Ian Bicking ianb at
Tue Nov 13 20:58:31 CET 2001

Erik Max Francis <max at> wrote in message news:<3BEE09CD.FFC433CC at>...
> Java _is_ object-oriented, so I don't see how this is a negative.  Note
> that object orientation looks a little different in message-oriented
> languages (such as Smalltalk or Objective C) rather than in
> call-oriented languages (like C++, Java, or Python).  

If you look under the hood, Python is much more like Smalltalk than
Java.  The message-passing of smalltalk is the same as a function call
-- though the syntax obscures that.  The (subtle) difference between
message-passing and method-calling is that message passing *sends*
something to the object, while calling *calls* something.  Calling
implies that the language pretty much knows what's being called before
it calls it.

Python is really sending, not calling.  You don't (ever) know before
runtime what function definition is going to be invoked.  By
overriding __getitem__ and other special methods, you can make the
object fully dynamic -- just like you can do in Smalltalk, but can't
do in Java.  (There are some holes in Python with respect to this, but
they are all being filled so they should be ignored for this argument)

Maybe to explain this a bit more: in Smalltalk every method call is
like sending a message to the object.  So when you do (someObject
moveTo: 10) you are actually sending (#moveTo:, 10) to the object,
which it can interpret as it wants.  It usually searches its class for
a method definition named #moveTo:, but it does not have to.  The
exact same thing happens in Python.  when you do
(someObject.moveTo(10)) in python, you are sending ("moveTo", 10) to
the object.  Most of the time it searches the class for a method named
"moveTo", but the object can really do anything it wants with it. 
This is why both Python and Smalltalk are message passing languages.

Python starts out from somewhere different than Smalltalk --
particularly that it's default object model is much more concrete and
not altogether as regular.  But you can go to all the same places. 
And what makes Smalltalk so cool -- that you can have so much power
over the language and objects, so that an object can pretend to be
anything you want it to be -- is also true for Python.  And it's
getting truer all the time as 2.x progresses.

More information about the Python-list mailing list