Created
January 25, 2018 12:48
-
-
Save AnjaneyuluBatta505/aa1d3e87c23b3ee327c37ff56b89b780 to your computer and use it in GitHub Desktop.
deep attribute lookup
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 mgetattr(obj, lookup): | |
# deep attribute lookup | |
for attr in lookup.split('.'): | |
obj = getattr(obj, attr) | |
return obj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment