4 ms·
> Am I the only one who wants multi-lined anonymous functions in Python? Lots of people want them (lots of people don't, too), but no one has come up with a gr
by dragonwriter 7y ago
> Am I the only one who wants multi-lined anonymous functions in Python?
Lots of people want them (lots of people don't, too), but no one has come up with a great syntax that plays nice with the rest of Python and saves you much over named functions.
- mantap 7y agoHey Pythonistas x('.b', onclick=func ev: print("clicked") end) You're welcome.
- pansa2 7y ago`end`? In my Python?!
- mantap 6y agoIt's more likely than you think. You need some end delimiter, it doesn't matter what it is as long as there is one. Just like list literals end with ] and dict literals end with } and str literals end with " or ' etc.
- zild3d 6y ago> it doesn't matter what it is as long as there is one of course it matters, there are design decisions in languages. a certain pattern or syntax may feel just right in one language but very much wrong in another. Throwing in an `end)` like that feels wrong in python https://www.python.org/dev/peps/pep-0020/ https://www.python.org/dev/peps/pep-0020/
- mantap 6y agoIt doesn't matter functionally. You can make the end token "waffleiron" or "mariahcarey" or "%^*~$". But there does need to be an end token to make multiline lambdas work and recognizing that is the first step to solving the problem. Once you have the scaffolding of the syntax you can turn it over to the bikeshedders on the mailing list to make it pretty.