On Wed, Feb 17, 2021 at 07:03:55PM +0000, Gustavo Carneiro wrote: > Just my 2c, I don't find lambda verbose at all, quite like it. > > But I wish Python allowed for multi-line lambda functions... somehow.
Python allows for multi-*line* lambda: lambda key, value, condition, sep='', default='': ( compute_prefix(key) + sep.join([str(expression or default) for obj in lookup(key, value) if condition(obj)] ) + compute_suffix(key) ) What it doesn't allow is multi-*statement* lambda; lambda is limited to a single expression. Although I have heard from Ruby enthusiasts that the ability to write large, complex, multi-statement anonymous block functions is really useful, its not something I can personally say I have missed. I think that once you get past a fairly simple one-line expression, anything else ought to be tested; and that requires making it a named function at the top level so that doctest or unittest can see it. -- Steve _______________________________________________ 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/AWP6IPKTD6WYTBUCHZ4NWD2MJ6OLZLQ3/ Code of Conduct: http://python.org/psf/codeofconduct/