In [5]:
a = 1
def f(b):
print(a, b)
f(3)
a = 2
f(8)
In [1]:
a = 1
def f(b):
a = 10
print(a, b)
f(3)
print(a)
In [2]:
a = []
def f(b):
a.append(5)
print(a, b)
f(3)
print(a)
In [4]:
a = 1
def f(b):
global a
a = 10
print(a, b)
f(3)
print(a)
In [3]:
def make_func(a):
def func(b, c):
print(a, b, c)
return func
f = make_func(1)
f(2, 3)
In [7]:
def make_gt_predicate(value):
def predicate(x):
return x > value
return predicate
filter(make_gt_predicate(3), range(8))
Out[7]: