Created
November 26, 2013 16:47
-
-
Save goliatone/7661709 to your computer and use it in GitHub Desktop.
This file contains hidden or 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_class( kls ): | |
| parts = kls.split('.') | |
| module = ".".join(parts[:-1]) | |
| m = __import__( module ) | |
| for comp in parts[1:]: | |
| m = getattr(m, comp) | |
| return m | |
| D = get_class("datetime.datetime") | |
| D.now() | |
| """ | |
| """ | |
| get_class = lambda name: reduce(getattr, name.split('.')[1:], __import__(name.partition('.')[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment