7 ms·
Unshamed plug of my project lambdex, which I worked out years ago to bring multilined lambda expressions in Python. https://github.com/hsfzxjy/lambdex https:/
by hsfzxjy 3y ago
Unshamed plug of my project lambdex, which I worked out years ago to bring multilined lambda expressions in Python.
https://github.com/hsfzxjy/lambdex https://github.com/hsfzxjy/lambdex
- exyi 3y agoNice :) Today it's possible to do a lot of it with vanilla Python (sortof): something(lambda x: [ x2 := x + 10, # define variables [ print(f"Number: {i}) for i in range(x) ], # loop [ 0 for i in range(x) if print(f"Number: {i}") or True if print(f"Second line: {i}") ], # loop if you prefer "normal code order" 0 if x > 0 else {}[f'{n} should be positive'], # conditions and asserts (throws KeyError, but includes the error message) x2 * 2 # return ][-1]) note: I'm not responsible for coworkers injuring you after committing this
- remram 3y ago> in an idiomatic manner Come on. No. It has the benefit of working, but definitely not being idiomatic.