Skip to content

Instantly share code, notes, and snippets.

@wcarhart
Last active February 6, 2020 23:51
Show Gist options
  • Save wcarhart/cf3944f3a62415406f8bd92c427173e5 to your computer and use it in GitHub Desktop.
Save wcarhart/cf3944f3a62415406f8bd92c427173e5 to your computer and use it in GitHub Desktop.
def jsonize(self):
variables = [var for var in dir(self) if not var.startswith(('_', '__')) and not callable(getattr(self, var))]
return "{" + ",".join([f"\"{var}\": \"{getattr(self, var)}\"" for var in variables]) + "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment