A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

Paul Boddie paul at boddie.org.uk
Tue Oct 17 13:33:43 CEST 2006


Theerasak Photha skrev:
> On 14 Oct 2006 09:25:00 -0700, Paul Boddie <paul at boddie.org.uk> wrote:
>
> > Unlike Java, Python's first class functions and
> > methods are already highly useful for callback-based systems
>
> Curious: how well does the use of returning inner functions work as a
> strategy for providing effectively 'anonymous' callbacks? e.g.
>
> def outer(x):
>   def inner(y):
>     ...
>   return inner

Well enough, I'd imagine. There may be people who resent having to use
a statement to create a block of code, especially one which defines a
local name (the horror!), but as the lambda replacement discussions
showed, a sub-statement code block doesn't necessarily have an
acceptable formulation in non-Lisp-like languages. Or, at least, people
struggled to find such a formulation in Python which didn't severely
affect readability, and there are people who regard even
uncontroversial but related things as list comprehensions as being much
less readable than most other constructs in the language.

Paul




More information about the Python-list mailing list