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

Stephen Horne steve at ninereeds.fsnet.co.uk
Sat Mar 27 11:28:25 EST 2004


On Fri, 26 Mar 2004 13:55:04 -0600, DH <no at sp.am> wrote:

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

It isn't really specifying anything. It is just validating, which we
can do already using normal code. Using decorators to validate
arguments/return types brings them to the front, thus making them more
useful as an example of self-documenting code, but while it's an
interesting application for decorators I don't think it should be
overemphasised.

Ensuring that a parameter has a specific type is often excessive in
Python - if another type supports the right methods in the right way,
it often makes sense to call the function with arguments of that type.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk



More information about the Python-list mailing list