IsPython really O-O?

Adam Spitz adamspitz at
Tue Nov 13 19:22:02 CET 2001

Tim Hammerquist wrote:

> Adam Spitz <adamspitz at> graced us by uttering:
> > For what it's worth, I consider myself a Smalltalker, and I like
> > Python very much. I don't give a hoot about OO purity - I like
> > Smalltalk because I'm really productive in it, and I like Python for
> > the same reason. (Ruby, too. ;)
> This is the exact reason I included that phrase. =) Also, it might have
> been an unconscious attempt to bring some of the less argumentative
> Smalltalkers out of hiding.

OK, I'm out of hiding. :) Anything in particular you'd like to

> Before your post, every Smalltalker I'd talked to said something very
> similar to "That's alright, but if you want a _real_ OO language,
> look at Smalltalk."

I *do* think that Smalltalk's got some advantages over Python, but I
don't think they're in the area of OOness. In terms of OO, Python has
everything I want.

Does anybody mind if I gripe a bit? (If you do, stop reading now. :) I
don't mean to piss anybody off. I'd just like to offer an outsider's
perspective. I promise to be as unbiased as I know how to be.

I'd be interested to see the current state of Python development
environments. That's where Smalltalk really shines, and I've never
seen an environment for any other language even come close. That's
understandable, because Smalltalk's whole, um, paradigm is optimized
for that kind of thing. Holding everything inside a monolithic image
makes it really easy to create spectacular tools (but, of course, also
costs Smalltalk a lot, like the ability to use Smalltalk for small
scripts). In particular, I'd like to see the Python Refactoring
Browser efforts bear fruit.

I'm kinda annoyed about Python's silly type/class distinction. But
then, so are you, and I'm glad to see the efforts at unification

I'm also kinda annoyed that Python introduced generators, list
comprehensions, and crippled lambdas to deal with an issue that
Smalltalk solves very neatly with its blocks. Still, most of my use of
blocks in Smalltalk is for conditionals (done in Python with nice,
plain "if" statements), and #do and #select and #collect (done in
Python with "for" statements and list comprehensions, and I kinda like
having the more convenient syntax). So in real life, most of the time
I don't even notice the lack of blocks. (I was surprised to realize
this. I'd like to know if other Smalltalk/Ruby programmers'
experiences with Python have been the same.)

I'd like to see Python stop hiding its dynamic side. I had a
discussion with some Python folks over at Ward Cunningham's Wiki
( a while ago, and I left with the impression
that Python was dynamic enough to do the things that I wanted, but
forced me to jump through some hoops to do them. (And that really
surprised me, because I *know* that the Python community takes pride
in Python's dynamicness and intuitiveness.) First example that comes
to mind: adding methods to an existing class. In Smalltalk, I'd just
browse over to that class and add the method. In Ruby, I'd just write:

class MyClass
  def newMethod()
    print "new method"

... and it'd add the new method to the class. In Python, I think I
have to define the method as a function *outside* the class and then
assign it as an attribute on the class:

def MyClass_newMethod(self):
  print "new method"
MyClass.newMethod = MyClass_newMethod

I smiled just now when I realized that the Python version is actually
fewer lines of code. :) But I still don't think it feels right. In
Smalltalk and Ruby, I'm just using the standard mechanism for adding
methods to a class. In Python, it feels like I'm sneakily hacking an
extra method into a class against its will. (Does that make any sense?
Maybe I'm being too touchy-feely. :)

(Sorry for digressing into Ruby. I just wanted to point out there *is*
an intuitive syntax - at least, a syntax that *I* find intuitive :) -
for this sort of thing, even for conventional file-based languages.)

Oh, and I've been meaning to ask - is there a way for me to add
methods to Dict or List or String? I couldn't figure out how to do it,
and that's where I *really* want it.

Anyway, I'd better stop now. I don't want to piss too many people off
too quickly. :) I really do like Python a lot, and I'd be delighted if
I ever got the opportunity to use it in an actual work environment.
(If I had any control over my life, I'd push for it. ;) But maybe it's
useful to hear the perspective of an almost-reasonable person from
outside the community.

Adam Spitz

More information about the Python-list mailing list