Skip to content

Instantly share code, notes, and snippets.

@nomeyer
Created May 30, 2016 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomeyer/a78ab4261d3dce3e4e322644d9ad2eaa to your computer and use it in GitHub Desktop.
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
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