Default constructor parameters in pyyaml
问题 I haven't been able to find out how to do this in the PyYAML documentation. I want to represent python classes I've defined in YAML, and have a default value given to a parameter in the constructor if it's not specified in the YAML. For example: >>> class Test(yaml.YAMLObject): ... yaml_tag = u"!Test" ... def __init__(self, foo, bar=3): ... self.foo = foo ... self.bar = bar ... def __repr__(self): ... return "%s(foo=%r, bar=%r)" % (self.__class__.__name__, self.foo, self.bar) ... >>> yaml