[Python-ideas] Ruby-style Blocks in Python Idea

Steven D'Aprano steve at pearwood.info
Mon Mar 9 18:50:56 CET 2009

On Tue, 10 Mar 2009 04:15:13 am you wrote:
> Hey Steven,
> > Can you explain why:
> >   func(named_function)
> > is radically different from:
> >   func(multi-line-code-block-without-the-name)
> Hmz, the intention isn't to support multi-line lambdas. It's to make
> passing in anonymous functions easier.

Lambdas are single-line (technically, single-statement) anonymous 
functions, and it's already easy to pass them in:

caller(lambda args: statement)

A multi-line lambda (technically, multi-statement) would also be an 
anonymous function. Your syntax:

using caller (args) do:
    multiple lines 
    making an 
    anonymous function

seems to me to be defining a multi-line lambda. The three lines of the 
indented block are exactly equivalent to the statement of a lambda. 
What is the difference that you see?

Steven D'Aprano

More information about the Python-ideas mailing list