Using the python object constructor capability of YAML, I am trying to
saparate object attributes in those that are not configurable (set at
init time by the application code) and in those that are configurable
(loaded at init time by YAML). One possible solution is in the following
example. I dont like it very much, there is any better way to do it?
Thanks in advance for any help.
====
#!/usr/bin/python
import yaml
class Test(yaml.YAMLObject):
yaml_tag = u'!Test'
def __init__(self,init_attr):
self.init_attr = init_attr
def __repr__(self):
return "%s(init_attr=%r,yaml_attr=%r)" % (self.__class__.__name__,
self.init_attr,self.yaml_attr)
test = yaml.load("""
--- !Test
yaml_attr: attribute from yaml
""")
test.__init__('attribute from init')
====