[Python-ideas] Syntax for passing lambdas to functions
Nick Coghlan
ncoghlan at gmail.com
Thu Feb 27 11:17:56 CET 2014
On 27 Feb 2014 17:33, "Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote:
>
> 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)
Let's talk about that for a moment. It would be a matter of making this:
NAME(ARGSPEC) = EXPR
syntactic sugar for this:
def NAME(ARGSPEC): return EXPR
Not what you would call a big win.
Cheers,
Nick.
>
> --
> Greg
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140227/4238c1e8/attachment.html>
More information about the Python-ideas
mailing list