I want to have a custom function that serializes arbitrary python objects, for example, as the json.dump function has an optional arg argument called "default", which should be the function that jum-dumper will call if the object is not json serializable.
I just want to make the equivalent of this from a json package.
json.dump(tests_dump, file('somefile', 'w+'), default = lambda x: x.__dict__)
It looks like I need to write yaml.add_representer from PyYAML docs, but it's really not clear how to do this.
source share