Inner function created every time the outer function runs


Also defined during run-time, but in every call of bar() the innter_func is redefined again and again.


examples/advanced/runtime-inner-def.py
import random

def foo():
    return random.random()

print(foo())
print(foo())

def bar(a, b = foo()):

    def inner_func(x, y = foo()):
        return [x, y]

    print('inner', inner_func(a))
    return [a, b]

print(bar(1))
print(bar(2))

0.821210904648
0.925337844251
inner [1, 0.9243163421154859]
[1, 0.38535850141949013]
inner [2, 0.5665772632462458]
[2, 0.38535850141949013]