What's better about Ruby than Python?

Jeffrey P Shell elw at euc.cx
Thu Aug 21 15:24:06 EDT 2003


Alex Martelli <aleaxit at yahoo.com> wrote in message news:<bhsrta02nai at enews3.newsguy.com>...

> As for me, I have no special issue with "having to specify self" for
> functions I intend to use as bound or unbound methods; otherwise I
> would no doubt have to specify what functions are meant as methods
> in other ways, such as e.g.
> 
>    def [method] test(what, ever):
>       ...
> 
> and since that is actually more verbose than the current:
> 
>    def test(self, what, ever):
>       ...
> 
> I see absolutely no good reason to have special ad hoc rules, make
> "self" a reserved word, etc, etc.  Python's choices are very simple
> and work well together (for the common case of defining methods
> that DO have a 'self' -- classmethod and staticmethod are currently
> a bit unwieldy syntactically, but I do hope that some variation on
> the often-proposed "def with modifiers" syntax, such as

It's especially nice that if you don't want to use 'self', you don't
have to.  Comfortable with 'this' from Java and friends?

    def test(this, what, ever):
        this.goKaboom(what*ever-what)

will work just fine.  'self' is just a ferociously common idiom.  But
it's only an idiom.  I like that.  So even if we used [method] as a
function decorator, I'd still prefer to see 'self' as part of the
signature.  I just like knowing where my names come from.

I do like the concept of function/method decorators though.  I'll have
to revisit that PEP.

--
J.Shell; http://toulouse.amber.org/




More information about the Python-list mailing list