Multi-line lambda as last argument
23 Feb
2021
23 Feb
'21
6:48 p.m.
Hello, Multi-line lambda is element of many languages, but they are not needed in the form in which they are made in many languages. А good use would be to use the lambda as the last argument of the function. Syntax:
def func(lambda1): lambda1()
func(): print(1)
Can be used for create dsl. For example html:
html: head()
body(): p(): "Hello world" a(href="python.org"): "Python link"
Or for create new syntax constructions:
def unless(condition, _lambda): if not(condition): _lambda()
unless(0): print('yes')
1156
Age (days ago)
1156
Last active (days ago)
0 comments
1 participants
participants (1)
-
Aleksey Ploskov