Created
May 30, 2016 12:25
-
-
Save nomeyer/a78ab4261d3dce3e4e322644d9ad2eaa to your computer and use it in GitHub Desktop.
Method to be able to call dict() on Python objects and get a dictionary of attribute values
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 __iter__(self): | |
for attr, value in self.__dict__.iteritems(): | |
yield (attr, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment