Skip to content

Instantly share code, notes, and snippets.

@afonasev
Created August 6, 2015 13:28
Show Gist options
  • Save afonasev/9c50ab72f9ff10d76906 to your computer and use it in GitHub Desktop.
Save afonasev/9c50ab72f9ff10d76906 to your computer and use it in GitHub Desktop.
def get_obj_by_path(path):
"""
Example:
obj = get_obj_by_path('module.Object')
"""
module_path, target = path.rsplit('.', maxsplit=1)
module = __import__(name=module_path, fromlist=(target,))
return getattr(module, target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment