PyYAML constructor with mixed attributes

Fabrizio Pollastri <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
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')
====

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.