title: Creating Custom Tag in PyYAML
body: <p>I'm trying to use Python's PyYAML to create a custom tag that will allow me to retrieve environment variables with my YAML.</p>
  
  <pre><code>import os
  import yaml
  
  class EnvTag(yaml.YAMLObject):
      yaml_tag = u'!Env'
  
      def __init__(self, env_var):
         self.env_var = env_var
  
      def __repr__(self):
         return os.environ.get(self.env_var)
  
  settings_file = open('conf/defaults.yaml', 'r')
  settings = yaml.load(settings_file)
  </code></pre>
  
  <p>And inside of <code>defaults.yaml</code> is simply:</p>
  
  <pre><code>example: !ENV foo
  </code></pre>
  
  <p>The error I keep getting:</p>
  
  <pre><code>yaml.constructor.ConstructorError: 
  could not determine a constructor for the tag '!ENV' in 
  "defaults.yaml", line 1, column 10
  </code></pre>
  
  <p>I plan to have more than one custom tag as well (assuming I can get this one working)</p>