I can figure out the behaviour of python. Here is code example:
def foo():
print('hello from initial foo')
def using_foo():
foo()
def wrapper(func):
def foo():
print('Now is overload foo')
print('Hello from wrapper')
func()
using_foo()
wrapper(using_foo)
This will print:
hello from initial foo
Hello from wrapper
hello from initial foo
But I expect:
hello from initial foo
Hello from wrapper
Now is overload foo
Because next one works fine:
def foo():
print('Hello from initial foo')
def using_foo():
foo()
using_foo()
if True:
def foo():
print('now it is overload foo')
using_foo()
Output:
Hello from initial foo
now it is overload foo