Created
July 14, 2015 22:33
-
-
Save studiotomi/18cf6c91e80da680d5a3 to your computer and use it in GitHub Desktop.
Find what base class an attributes is coming from in Python
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 find_attribute_class(model, attribute): | |
""" | |
If the attribute is found, it returns an array of places the attribute is defined. | |
The array is ordered by priority, the first element being the one that is called. | |
If not found, returns an empty array. | |
""" | |
return [m for m in model.mro() if attribute in m.__dict__] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment