Skip to content

Instantly share code, notes, and snippets.

@balkian
Last active October 30, 2021 10:53
Show Gist options
  • Save balkian/ddbd2be15e20eb81de1a to your computer and use it in GitHub Desktop.
Save balkian/ddbd2be15e20eb81de1a to your computer and use it in GitHub Desktop.
Add properties to serializable
cls = self.__class__
property_names=[]
for p in dir(cls):
if isinstance(getattr(cls, p), property):
property_names.append(p)
logging.debug('property names: {}'.format(property_names))
for p in property_names:
ser['@%s' % p] = getattr(cls, p).fget(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment