[Python-ideas] A simple proposal concerning lambda

Chris Angelico rosuav at gmail.com
Tue Aug 21 22:52:29 EDT 2018


On Wed, Aug 22, 2018 at 12:48 PM, Abe Dillon <abedillon at gmail.com> wrote:
> [Steven D'Aprano]
>>
>> Replacing the keyword:
>>     results = map(def a, b=2, c=3: a ** b / c, sequence)
>>     widget.register(callback=def: spam.eggs())
>> Doesn't look so attractive now, I wager. Using "def" inside an
>> expression looks strange. And this looks outright disturbing:
>>     def method(self, arg, callback=def arg: arg+1):
>>         pass
>
>
> Eh... I think they look fine. Which is worse:
>
> def method(self, arg, callback=def arg: arg+1):
>     pass
>
> or
>
> lambda arg, callback=lambda arg: arg+1: None
>
> because the second one makes me go cross-eyed...

If you have a use-case for a lambda function that takes a callback and
has a default value for that callback, please submit it to The Daily
WTF. In Steve's example, the main function was created with a
statement.

ChrisA


More information about the Python-ideas mailing list