Functions can be defined inside functions.

examples/advanced/sub_in_sub.py
def f():
    print("in f")
    def g():
       print("in g")
    g()

f()
#g()  # does not exist here

They are scoped locally