I want to pass a method as an argument that will call such a method from another python file as follows:
file2.py
def abc():
return 'success.'
main.py
import file2
def call_method(method_name):
return file2.method_name()
print(call_method(abc))
I expect to return success.
If you call the method in the same file (main.py), I notice that it is working. However, for a case like the one above, where it involves passing an argument called from another file, how can I do this?
source
share