proposed syntax for multiline anony-functions (hopefully?)
alex23
wuwei23 at gmail.com
Fri Aug 22 01:15:32 EDT 2014
On 21/08/2014 7:30 PM, icefapper at gmail.com wrote:
> On Thursday, August 21, 2014 2:27:08 AM UTC-7, Marko Rauhamaa wrote:
>> In practice, your proposal would not make life easier for Python
>> programmers.
>
> neither did the lambda, yours truly supposes?
alex23 disagrees. alex23 finds the lambda extremely convenient for
things like sort, filter etc where alex23 wants to provide a function.
alex23 finds this to be very readable:
odds_list = filter(lambda x: bool(x % 2), some_list)
By comparison, alex23 finds this to be more cumbersome for little gain:
def odds_only(x):
return bool(x % 2)
odds_list = filter(odds_only, some_list)
alex23 finds most examples for multiline anonymous functions to be far
more difficult to parse than the both restricted lambda form and the
separate function approach:
odds_list = filter((def(x):
return bool(x % 2)), some_list)
alex23 isn't even sure if that's the correct format for your proposed
syntax, or whether `, some_list)` has to appear on a separate line, or
even if the () around the anonymous function is even necessary (alex23
assumed it was from your description of the closing parenthesis popping
the "space-sensitivity-stack").
More information about the Python-list
mailing list