File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ # Author: OMKAR PATHAK
2+
3+ # Wikipedia:
4+ # A closure is a record storing a function[a] together with an environment:
5+ # a mapping associating each free variable of the function (variables that are used locally, but
6+ # defined in an enclosing scope) with the value or reference to which the name was bound when
7+ # the closure was created.A closure—unlike a plain function—allows the function to access those
8+ # captured variables through the closure's copies of their values or references, even when the function
9+ # is invoked outside their scope.
10+
11+ def outerFunction (text ):
12+ text = text
13+
14+ def innerFunction ():
15+ print (text )
16+
17+ return innerFunction
18+
19+ if __name__ == '__main__' :
20+ myFunction = outerFunction ('Hey!' )
21+ myFunction ()]
You can’t perform that action at this time.
0 commit comments