PEP 318

John Roth newsgroups at jhrothjr.com
Sun Mar 21 21:29:48 CET 2004


"Nicolas Fleury" <nid_oizo at yahoo.com_removethe_> wrote in message
news:Xjm7c.3373$p8.414038 at weber.videotron.net...
> Marco Bubke wrote:
> > def foo(x, y) as staticmethode: pass
> >
> > Define foo with arguments x and y as staticmethode.
> >
> > Is Python now C++? Mabe I miss something why this syntax is wrong.
>
> Personnally, I prefer the "as" syntax to the other proposed (and by a
> large margin).  However, I feel that it is making the language more
> complex and I'm far from sure it's worth the effort.  I've given some
> Python courses, and the first reaction when showing a class with some
> methods is something like "so I guess when the first parameter is not
> named 'self' it makes a class method?".  So I have to explain it's not
> the case, etc.
>
> If easing the creation of class methods is so important, I would prefer
> a more radical approach with a end result that would be more intuitive
> to newcomers:
> - Give a warning for all methods with first parameter not named "self"
> in next versions of Python.
> - In a future major version of Python, 3 or 4, self becomes a keyword
> and a first parameter named otherwise implies a class method (I
> understand it could mean a lot of changes in code not using self).
>
> Regards,
>
> Nicolas

I personally think that self not only should be a keyword,
it should not be among the parameters at all. However, I
seem to be in a distinct minority about that.

However, I think you've got class methods mixed up with
static methods. Class methods require the first parameter
to be the class (sometimes spelled klas for some reason),
while static methods are the ones that don't have either an
instance or a class as the first parameter.

John Roth





More information about the Python-list mailing list