[Python-ideas] Syntax for passing lambdas to functions
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Feb 27 08:32:48 CET 2014
Chris Angelico wrote:
> It's
> problematic because it's still legal - if it threw a SyntaxError, it
> would at least be visible, but it doesn't:
>
> spam=fire_the_ducks(42)
> f(onclick()=spam)
That's equivalent to
spam = fire_the_ducks(42)
f(onclick = lambda: spam)
which is not a syntax error either, but it's just as wrong,
and I'm not convinced that it's a harder mistake to make.
For what it's worth, the following *could* be made to work:
spam() = fire_the_ducks(42)
f(onclick = spam)
--
Greg
More information about the Python-ideas
mailing list