[Tutor] Use of "or" in a lambda expression
boB Stepp
robertvstepp at gmail.com
Sat Apr 4 23:57:05 CEST 2015
On Sat, Apr 4, 2015 at 3:35 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> He could have done it in various other ways too:
>
> eg.
> lambda : all(print('Hello lambda world!'), sys.exit() )
Is this what you meant? Because print will always return False. Or did
you actually mean:
lambda: any(print('Hello lambda world!'), sys.exit())
> But the OR style is established as a kind of idiom,
> not just in Python but several other languages too.
So this is not unusual for Python. BTW, what are some of the other
languages where this type of expression might be commonly used?
--
boB
More information about the Tutor
mailing list