title: How to write to yaml file in human readable format?
body: <p><strong>I have some data types I need to write:</strong></p>
  
  <p>a. A list of numpy arrays, e.g. <code>[ndarray, ndarray, ndarray]</code> of different sizes.</p>
  
  <p>b. Any arbitrary numpy array, e.g. <code>np.zeros((5,6)), np.randn((76,2))</code> and so on.</p>
  
  <p>c. Any other future datatype that hasn't occurred to me yet.</p>
  
  <p><strong>Requirements:</strong></p>
  
  <ol>
  <li><p>I need a single function to be able to save all those data types, with no specific handling, and with future compatibility for type c stated above.</p></li>
  <li><p>I also need the output file dump in human readable format.</p></li>
  </ol>
  
  <p>So far, I was only able to achieve requirement 1 with either YAML or pickle, both of which with binary files, i.e. not human readable.</p>
  
  <pre><code>@staticmethod
  def _read_with_yaml(path):
      with open(path, 'r') as stream:
          return yaml.load(stream)
  
  @staticmethod
  def _write_with_yaml(path, obj):
      with io.open(path, 'w+', encoding='utf8') as outfile:
          yaml.dump(obj, outfile, default_flow_style=False, allow_unicode=True)
  </code></pre>
  
  <p>This example code outputs non-human-readable files, but works for the data types I have.</p>
  
  <p><strong>Is there a way to achieve both requirements?</strong></p>