[Python-ideas] @return?

Conrad Irwin conrad.irwin at googlemail.com
Thu Apr 15 01:33:16 CEST 2010


On 04/14/2010 11:07 PM, Mathias Panzenböck wrote:
> On 04/14/2010 11:52 PM, Nick Coghlan wrote:
>>
>> The problem is that:
>>
>> 1. Whitespace is highly significant in delineating scope and separation
>> at a statement level
>>
>> 2. Whitespace is largely insignificant at the expression level
>>
> 
> Maybe only allow them at certain places where they can be seen as an
> extension to an already existing statement syntax (not to an expression
> syntax):
> 
> foo.bar = def(egg, spam):
>     pass
> 
> return def(egg, spam):
>     pass
> 
> yield def(egg, spam):
>     pass
> 
> 

There are several places a value might be used:

    return/yield/throw
    rhs of an assignment
    inside a function call

When treating inline-functions as values, the first case is best handled
by @return - the same arguments about not putting decorators on the same
line as function name apply here too. I am also slightly against truly
"anonymous" functions, if it doesn't fit inside a lambda, the name at
least provides some compulsory documentation, and a reference point
while debugging.


I am of the opinion the rhs of assignment case is better handled by
allowing more flexible function names:

    def alpha.beta(val):
        pass


Allowing functions inside function calls is the topic for another day.

Conrad



More information about the Python-ideas mailing list