Skip to content

Commit e0577d0

Browse files
author
lev epshtein
committed
commit 1
1 parent fdb33b9 commit e0577d0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

closures/closure.func.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def print_msg(msg):
2+
# This is the outer enclosing function
3+
4+
def printer():
5+
# This is the nested function
6+
print(msg)
7+
8+
return printer # returns the nested function
9+
10+
11+
# Now let's try calling this function.
12+
# Output: Hello
13+
another = print_msg("Hello")
14+
another()
15+
16+

0 commit comments

Comments
 (0)