Commits

Andriy Kornatskyy committed d469be5

Added import_name.

Comments (0)

Files changed (1)

src/wheezy/core/introspection.py

+
+""" ``introspection`` module.
+"""
+
+from wheezy.core.comp import __import__
+
+
+def import_name(fullname):
+    """
+        >>> from datetime import timedelta
+        >>> import_name('datetime.timedelta') is timedelta
+        True
+    """
+    namespace, name = fullname.rsplit('.', 1)
+    obj = __import__(namespace, None, None, [name])
+    return getattr(obj, name)