bestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish · 30 days agoThe meaning of thislemmy.mlimagemessage-square57linkfedilinkarrow-up1493arrow-down112
arrow-up1481arrow-down1imageThe meaning of thislemmy.mlbestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish · 30 days agomessage-square57linkfedilink
minus-squarejacksilver@lemmy.worldlinkfedilinkarrow-up17·30 days agoMaybe I’m missing something, but: Python Lambda Functions - https://www.w3schools.com/python/python_lambda.asp Python map - https://www.geeksforgeeks.org/python-map-function/ They do have list comprehension, which let you basically one line a map operation more intuitively too.
minus-squareNatanox@discuss.tchncs.delinkfedilinkEnglisharrow-up5·edit-230 days agoAnd switch cases (called match cases) are there as well. I use lambdas all the time to shovel GTK signal emitions from worker threads into GLib.idle_add in a single line, works as you’d expect. Previous commenters probably didn’t look at Python in a really long time.
minus-squareJumuta@sh.itjust.workslinkfedilinkarrow-up1·29 days agoi mean tbf match case was only added in 3.10
minus-squarevrighter@discuss.tchncs.delinkfedilinkarrow-up4arrow-down1·29 days agoa lambdo which can only contain one expression, and not even a statement is pretty much useless. For anything nontrivial you have to write a separate function and have the lambda be just a function call expression. Which completely defeats the point
Maybe I’m missing something, but:
And switch cases (called match cases) are there as well.
I use lambdas all the time to shovel GTK signal emitions from worker threads into GLib.idle_add in a single line, works as you’d expect.
Previous commenters probably didn’t look at Python in a really long time.
i mean tbf match case was only added in 3.10
a lambdo which can only contain one expression, and not even a statement is pretty much useless. For anything nontrivial you have to write a separate function and have the lambda be just a function call expression. Which completely defeats the point