learnbyexample@programming.dev to Python@programming.devEnglish · 6 months agoA Guide to Python Lambda Functionsadamj.euexternal-linkmessage-square8fedilinkarrow-up134arrow-down10
arrow-up134arrow-down1external-linkA Guide to Python Lambda Functionsadamj.eulearnbyexample@programming.dev to Python@programming.devEnglish · 6 months agomessage-square8fedilink
minus-squaresugar_in_your_tea@sh.itjust.workslinkfedilinkarrow-up2·6 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.