Last active
September 14, 2022 18:14
-
-
Save divs1210/685cb671d38bff0304b8591fe0ef640a to your computer and use it in GitHub Desktop.
Dead Simple Multiline Lambdas for Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do(*body): | |
return body[-1] | |
# Example (Python 2) | |
# ======= | |
map(lambda x: do( | |
print('x =', x), | |
x * x), | |
range(5)) | |
""" | |
x = 0 | |
x = 1 | |
x = 2 | |
x = 3 | |
x = 4 | |
[0, 1, 4, 9, 16] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment