The problem with "as" [was "Re: PEP 318"]

DH no at sp.am
Mon Mar 22 19:34:32 EST 2004


Paul Rubin wrote:
>"def foo() as staticmethod" certainly looks best to me aesthetically.

It does look better with simple examples.  But think of other potential 
uses for an "as" keyword, and it might have problems.
Visual Basic uses "as" in function declarations to declare types, not 
for function decorators.
VB example:
Function foo (x as Integer, y as Float) as Integer

Possible future Python example that uses "as" differently:

def foo(x as int, y as float) as int:
    "this function returns an integer, and takes an int & float params"

If we use the list syntax for decorators instead of "as", we might be 
able to do something like:

def foo(x as int, y as float) [synchronized, classmethod] as int:
    ...

See this thread:
http://mail.python.org/pipermail/python-dev/2004-February/thread.html#42780



More information about the Python-list mailing list