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

DH no at sp.am
Fri Mar 26 14:55:04 EST 2004


Christian wrote:

> IMHO, if the function's name has to be right after the 'def', and 'def'
> has to be the first command in a declaration, the return type has to
> come last

I agree.

I think it is neat that function decorators may be used for specifying 
argument types and the return types, but I don't think it should be THE 
way to always do it, because it is pretty ugly.  I still prefer 
eventually adding an "as" keyword or some other different syntax from 
the decorator syntax, like:

def foo(x as int, y as float) as string:
    ...

See: http://mail.python.org/pipermail/python-dev/2004-February/042795.html

I know that is like Visual Basic, but it is readable and easier to 
understand for novices.  If you want to use x:int, y:float instead, you 
might as well throw out the colon at the end of the def statement since 
it defeats the purpose of it.



More information about the Python-list mailing list