Created
August 6, 2015 13:28
-
-
Save afonasev/9c50ab72f9ff10d76906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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