python - Call a function of the importer -
i'm new python, , trying create module. went fine, until had call function of file calling module. used pass function argument, , worked:
def my_function(..., ..., func, ..., ...):
then call as:
func()
but realized function name should not change in particular case, , should call same function, call update()
i tried omitting argument , instead calling function normal, if function in same module. didn't work. tried using exec
, didn't work either. i'm not sure how use getattr()
because first argument can vary based on module name.
how call function of importer? (sorry if title confusing)
there's no way function can know imported (except possibly via extremely horrible stack inspection, absolutely don't want do). don't know why think referring function if in same module work; state, not in same module.
i can't thinking want here class: need send both data , function, should wrapped in class instance send instead.
Comments
Post a Comment