title: Dumping Collection to YAML file with PyYaml
body: <p>I am writing a python application. I am trying to dump my python object into yaml using PyYaml. I am using Python 2.6 and running Ubuntu Lucid 10.04. I am using the PyYAML package in Ubuntu Package: <a href="http://packages.ubuntu.com/lucid/python/python-yaml" rel="nofollow noreferrer">http://packages.ubuntu.com/lucid/python/python-yaml</a></p>
  
  <p>My object has 3 text variables and a list of objects. Roughly it is something like this:</p>
  
  <pre><code>ClassToDump:
  
     #3 text variables
     text_variable_1
     text_variable_2
     text_variable_3
     #a list of AnotherObjectsClass instances
     list_of_another_objects = [object1,object2,object3]
  
  
  AnotherObjectsClass:
     text_variable_1
     text_variable_2
     text_variable_3
  </code></pre>
  
  <p>The class that I want to dump contains a list of AnotherObjectClass instances. This class has a few text variables.</p>
  
  <p>PyYaml somehow does not dump the collections in AnotherObjectClass  instance. PyYAML does dump  text_variable_1, text_variable_2, and text_variable_3. </p>
  
  <p>I am using the following pyYaml API to dump ClassToDump instance:</p>
  
  <pre><code>classToDump = ClassToDump();
  yaml.dump(ClassToDump,yaml_file_to_dump)
  </code></pre>
  
  <p>Does any one has any experience with dumping a list of objects into YAML ?</p>
  
  <p>Here is the actual full code snippet:</p>
  
  <pre><code>def write_config(file_path,class_to_dump):    
      config_file = open(file_path,'w');  
      yaml.dump(class_to_dump,config_file);
  
  def dump_objects():
  
  rule = Miranda.Rule();
  rule.rule_condition = Miranda.ALL
  rule.rule_setting = ruleSetting
  rule.rule_subjects.append(rule1)
  rule.rule_subjects.append(rule2)
  rule.rule_verb = ruleVerb
  
  write_config(rule ,'./config.yaml');
  </code></pre>
  
  <p>This is the output :</p>
  
  <p>!!python/object:Miranda.Rule
  rule_condition: ALL
  rule_setting: !!python/object:Miranda.RuleSetting {confirm_action: true, description: My
      Configuration, enabled: true, recursive: true, source_folder: source_folder}
  rule_verb: !!python/object:Miranda.RuleVerb {compression: true, dest_folder: /home/zainul/Downloads,
    type: Move File}</p>