Assuming that I have foo.py
like below.
This file is not created by me, so I want neither to modify nor copy this.
In other words, foo.py
is in some extra package I installed.
# foo.py
def bar():
print('This is bar')
def foo():
print('something')
bar()
print('something')
Then, I want to implement foo_as_baz()
behaving as comments.
# baz.py
from foo import foo
def baz():
print('This is baz')
def foo_as_baz():
"""
This function is expected to behave as below
print('something')
baz()
print('something')
"""
pass
I tried below one but it does not work since the namescope differs.
def foo_as_baz():
bar = baz # I expect this `baz` affects `bar` function in `foo`
foo()