You can define a named function inside a named function and thus limiting its scope.
def outer_func(): def inner_func(): print("hi") inner_func()
You can define a named function inside a named function and thus limiting its scope.