[Python-Dev] Wrappers and keywords
"Martin v. L÷wis"
Thu, 17 Apr 2003 22:12:19 +0200
David LeBlanc wrote:
> I am curious to know why the, what seems to me kludgy, "def x(): pass x =
> (static|class)method(x)" syntax was chosen over a simple "staticdef x
> ():..." or "classdef x ():..." def specialization syntax?
That syntax hasn't been chosen yet; syntactic sugar for static and class
methods, properties, slots, and other object types is still an area of
The current implementation was created since it did not need an
extension to the syntax:
was syntactically correct even in Python 1.2 (which is the oldest
Python version I remember).
There have been numerous proposals on what the syntactic sugar should
look like, which is one reason why no specific solution has been
implemented yet. Proposals get usually discredit if they require
introduction of new keywords, like "staticdef". The current favorite
proposals is to write
def x() [static]:
def x() [staticmethod]:
In that proposal, static(method) would *not* be a keyword, but would
be an identifier (denoting the same thing that staticmethod currently
denotes). This syntax nicely extends to
def x() [threading.synchronized, xmlrpclib.webmethod]:
The syntax has the disadvantage of not applying nicely to slots.