Created
December 7, 2021 00:38
-
-
Save terabyte/8b961c29eab7fd155ddbe115d7941326 to your computer and use it in GitHub Desktop.
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 default_serialize_func(o): | |
""" | |
Use like this: logging.debug(f"print this object: {json.dumps(myobject, indent=4, sort_keys=True, default=default_serialize_func)}") | |
""" | |
if hasattr(o, '__dict__'): | |
return o.__dict__ | |
return f"<could not serialize {o.__class__}>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment