[Python-ideas] Where-statement (Proposal for function expressions)

Jan Kaliszewski zuo at chopin.edu.pl
Sat Jul 18 07:52:18 CEST 2009


Ben Finney <ben+python at benfinney.id.au> wrote:

> Greg Ewing <greg.ewing at canterbury.ac.nz> writes:
>
>> In a sense, the where-block is in part an attempt to extend the
>> assignment statement so that the "right hand side" can span more
>> than one statement.
>
> That pretty much spells its doom, then. The BDFL is quite firm (as
> demonstrated in, e.g., the pronouncement against multi-line lambda
> <URL:http://www.python.org/dev/peps/pep-3099/>) that multi-statement
> expressions are verboten.

But where-statement is not an expression at all -- yet it's a sequence
of statements. And even in that PEP you can read that a new syntax for
anonymous functions would be welcone:

"At one point lambda was slated for removal in Python 3000.
Unfortunately no one was able to come up with a better way of providing
anonymous functions. And so lambda is here to stay."

IMHO 'where' would be better than lambda in many contexts, especially
if there is a need for function as argument, e.g. for filter(), map(),
sort(key=...) etc., and also for some list comprehensions and generator
expressions.

Regards,
-- 
Jan Kaliszewski <zuo at chopin.edu.pl>



More information about the Python-ideas mailing list