IsPython really O-O?

Tim Hammerquist tim at vegeta.ath.cx
Tue Nov 13 17:26:52 EST 2001


Adam Spitz <adamspitz at bigfoot.com> graced us by uttering:
> Tim Hammerquist wrote:
>> 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
> discuss?

Yes. Exactly what you here.  ;)

> 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.

My fave part of ST is how it handles the whole object _concept_.  As you
state, this make small scripts/programs unnecessarily complex/large, but
for anything sufficiently large it's amazing!

> 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
> progressing.

Agreed.

> 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.

Having come from Perl (and, BTW, still using/liking it), I found
list-comprehensions a welcome addition.  Oops!  I shouldn't have said
that.  There may be a PEP to remove them since they resemble a Perl
feature!

[ snip ]
> 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.

Dicts, lists, and strings are all "types", the downfalls of which you
mentioned earlier.  OTOH, someone must've had the some wish, because the
latest Python distro comes with the standard modules UserDict, UserList,
and UserString which provide inheritable classes (though slightly less
efficient) to do with whatever you wish.  Add a method, or simply
subclass.  (As the interface of the above types is fairly standard,
adding new methods would technically be a different object exhibiting
different behavior, deserving of its own class, right?)

I don't currently know of a way to make a custom(ized) String/List/Dict
class the default for the ''/[]/{} constructor, though.

> But maybe it's useful to hear the perspective of an almost-reasonable
> person from outside the community.

It has been for me.  Thx.

Tim Hammerquist
-- 
Anyone who thinks that the act of programming is worth
less than $50/hr should leave the industry.
    -- Randal L. Schwartz (clpm, 27 Jul 2000)



More information about the Python-list mailing list