From aafb04bb144dc50e39f34130a20e0c905ac143e5 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Thu, 9 Oct 2014 14:36:25 -0400 Subject: [PATCH] add utils and dynamic_import function --- qw/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 qw/utils.py diff --git a/qw/utils.py b/qw/utils.py new file mode 100644 index 0000000..83345b6 --- /dev/null +++ b/qw/utils.py @@ -0,0 +1,7 @@ +def dynamic_import(name): + module, _, function = name.rpartition(".") + mod = __import__(module, fromlist=[function]) + components = name.split(".") + for comp in components[1:]: + mod = getattr(mod, comp) + return mod