Let's say I have a good reason to have these 2 separate modules:
first_module.py
import second_module
def say_hello(user, text):
print(f"{text} -> {user}")
if __name__ == "__main__":
second_module.run(say_hello)
second_module.py
def run(func):
# here I want to modify the func function by removing the first parameter
# as stated above, func in this example is the say_hello from first_module.py
# I want to remove the user parameter and let only the text parameter
# is this even possible?
I tried to use lambda, something like this:
modified_method = lambda args, kw: func(*args[1:], **kw)
However, this didn't work
My expected result is to manipulate (modify or create a new version) the func function inside the run function. The reason is that the second_module.py
has no idea about the function say_hello at 'compile time'. Basically, second_module.py
is a library that will be used later by first_module.py
, so the run function inside second_module.py
needs to be generic