learnbyexample to PythonEnglish · 7 months agoA Guide to Python Lambda Functionsadamj.euexternal-linkmessage-square8fedilinkarrow-up136arrow-down10
arrow-up136arrow-down1external-linkA Guide to Python Lambda Functionsadamj.eulearnbyexample to PythonEnglish · 7 months agomessage-square8fedilink
minus-squaresugar_in_your_tea@sh.itjust.workslinkfedilinkarrow-up2·7 months agoThe general form is: (var := expression) rest of condition So you can do something awful like this: lambda: (y := 1) != 2 and y Not sure if that’s “good,” but it does kind of let you sneak a statement into the lambda.
The general form is:
(var := expression) rest of condition
So you can do something awful like this:
lambda: (y := 1) != 2 and y
Not sure if that’s “good,” but it does kind of let you sneak a statement into the lambda.