PEP 318

Skip Montanaro skip at pobox.com
Mon Mar 22 10:14:17 EST 2004


    >> - Give a warning for all methods with first parameter not named "self"
    >> in next versions of Python.

    Jacek> That would be acceptable ...

I suggest you see if PyChecker already does this.

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

    Jacek> ... that would (IMHO) not.

(I'm not picking on Jacek here.  I just chose to reply to his post.)

Everybody seems to be fixated on how best to spell "make this function a
class or static method".  If that was all we were interested in, something
more syntacically restrictive would be fine.  That's not all PEP 318 allows
though.  It proposes syntax (and eventually semantics) for a general
function decorator capability.

I almost wish Python didn't already have staticmethod() and classmethod()
builtins so people wouldn't get so hung up on the most economical way to
spell them.

I suggest people google for

    site:mail.python.org python-dev PEP 318

and look at some of the other ideas people have had or examples proposed of
how to (ab)use this feature.  It's applicability is much broader than just
declaring methods to be "static" or "class".

Skip




More information about the Python-list mailing list