Abdulla Al Kathiri wrote: > Oh I forgot what if you want to return a set from your lambda? Maybe a lambda > set should at least have one assignment statement to qualify it as one. > Expressions only inside a set syntax will be just a normal set that doesn’t > care about order as you pointed out. But a lambda set will care about the > order just like when you do a normal multi-lines def function. > def f(x): > print(x) > z = x + 3 > return z > Is equivalent to > (x) => {print(x), z = x + 3, z}
You can achieve this already with tuples and assignment expressions (not very readable though): lambda x: (print(x), z := x+3, z)[-1] _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DF2HYQODJIY7HHCK6FBP3URNVAEC6QD7/ Code of Conduct: http://python.org/psf/codeofconduct/