+ 3

Closures in python.👍

Closures is a.... Nested functions are able to access variables of the enclosing scope. ... Hence, here, innerFunction() is treated as nested Function which uses text as non-local variable. Python Closures. AClosure is a function object that remembers values in enclosing scopes even if they are not present in memory. def outerFunction(text): text = text def innerFunction(): print(text) return  innerFunction() if __name__ == '__main__': outerFunction('Hey!')

16th Mar 2018, 11:03 AM
Maninder $ingh
Maninder $ingh - avatar
1 ответ
+ 13
nice, but if you want share some lessons don't post here, use lesson factory instead
16th Mar 2018, 12:52 PM
Vukan
Vukan - avatar