[Python-ideas] Ruby-style Blocks in Python Idea (alternative)

Guido van Rossum guido at python.org
Tue Mar 10 17:33:27 CET 2009


On Tue, Mar 10, 2009 at 1:58 AM, spir <denis.spir at free.fr> wrote:
> Le Tue, 10 Mar 2009 01:13:42 +0100,
> Jan Kanis <jan.kanis at phil.uu.nl> s'exprima ainsi:
>
>> This being python-ideas, I'll also have a go at it.
>>
>> Being someone who does like functional programing when used in limited
>> quantities, I also think multi line lambdas (or blocks, whatever you
>> call them) are a good thing if a good way could be found to embed them
>> into Python. But I don't like the part of tavs proposal of handling
>> them with a magic __do__ function. So what about this slightly
>> modified syntax and semantics:
>>
>> def NAME(ARGS) [as OTHERNAME] with EXPRESSION_CONTAINING_NAME:
>>       BODY
>>
>> eg:
>>
>>  def callback(param) as result with do_something(with_our(callback),
>> other, args):
>>       print("called back with "+param)
>>       return foobar(param)
>
> I like this proposal much more than all previous ones.

Just to avoid getting your hopes up too high, this gets a solid -1
from me, since it just introduces unwieldy new additions to the
currently clean 'def' syntax, to accomplish something you can already
do just as easily with a decorator.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list