class MyClass:

    def __init__(self, someNumber, someString):
        self.var1 = someNumber
self.var2 = someString

def MyClass_representer(dumper, data):
    serializedData = str(data.var1) + '|' + data.var2
return dumper.represent_scalar('!MyClass', serializedData)
yaml.add_representer(MyClass, MyClass_representer)
obj = MyClass(100, 'test')
print("""original Object
var1:{0}, var2:{1}
""".format(obj.var1, obj.var2))
Как написать представителя для PyYAML?