Formatting custom class output in PyYAML
问题 I'm working on a simple example here, but the docs still leave me a bit confused. Here is the Example code: class A(yaml.YAMLObject): yaml_tag = u'!A' def __init__(self, val): self.val = val if __name__ == '__main__': t = datetime.time() a = A(t) print yaml.dump(a) print yaml.load(yaml.dump(a)).val == t The output is !A val: !!python/object/apply:datetime.time ["\0\0\0\0\0\0"] True So, it appears to be faithfully d-/serializing, but the default time object format leaves something to be