From: Ben Giddings Date: 2004-04-06T03:55:08+09:00 Subject: Re: deciding between ruby and python Vadim Nasardinov wrote: > class Foo: > "A poor man's closure" > > def __init__(self, state): > self.__call__ = self._call > self.state = state > > def _call(self, x, y): > return x * self.state + y > > > foo1 = Foo(1) > foo2 = Foo(42) > > print foo1(2,3) > print foo2(2,3) Ah yes, in one fell swoop, demonstrating almost all the things I find annoying about Python: * 'self' as the first parameter of methods, which is one of the sources of that whole "Python's OO is a hack" thing. Now you can argue that it's just a (very odd) style choice, but I can't help but see that as ugly and hackish. * Defining a method with 'n' parameters, calling it with 'n-1' parameters. An artifact of how Python's OO is done, but so very confusing and 'hackish' * __So__ __Many__ __Underscores__!! (self.__call__ = self._call)??? * Constructors look exactly like functions. No 'new' or any other similar hint that it's a constructor. All it's really missing is the mishmash of functional, imperative and OO programming like: ':'.join(map(lambda str: "0x%s"%str, mac_address.split(':'))) Python and Ruby are effectively equals. They take about the same amount of time to run a script, they have about the same level of abstraction. They're both dynamic typed. The only thing is: Python is ugly, Ruby is pretty. Now sure, beauty is in the eye of the beholder, but my eye prefers to behold Ruby. :) Ben