Add "import method from string" in new utils file
This commit is contained in:
parent
be01ac4b27
commit
708ea65163
12
utils/utils.py
Normal file
12
utils/utils.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import importlib
|
||||||
|
|
||||||
|
|
||||||
|
def import_method_from_string(file, method_name):
|
||||||
|
"""
|
||||||
|
Add the posibility to import method dynamically using a string like "intents.daily.date_and_time.intent" as file and
|
||||||
|
"what_time_is_it" as method_name
|
||||||
|
"""
|
||||||
|
mod = importlib.import_module(file)
|
||||||
|
met = getattr(mod, method_name)
|
||||||
|
|
||||||
|
return met
|
Reference in New Issue
Block a user