python - how to access variable and lambda defined inside a function(which is not defined in any class)? -
i have basic question. reason i'm not able recall how it. how access variables defined in function not declared in class. how access y
variable ? , how pass value lambda ? , how value of c
defined inside lambda ?
def fun (): y = 100 x = lambda c,s,y : c*s*y
also how pass values lambda function ?
if want use y
in lambda don't specify argument lambda:
def fun(): y = 5 x = lambda c, s: c*s*y return x(2, 3) >>> fun() 30
Comments
Post a Comment