Let's say I am writing a library module a.py like this
def call_func(f):
""" invoke func by its func str """
return eval(f)()
and the user define function is in module b.py,
from a import call_func
def b():
return "b"
call_func("b")
This will be an error since in module a, function b is not exposed. Since function b is in user space, from library a point of view, user defined function b is not known.
It might be possible to use a register function in a.py, but I don't know how to do it. Or maybe there are alternative ways?
Thanks!
Aucun commentaire:
Enregistrer un commentaire