title: Convert string to Enum in Python
body: <p>What's the correct way to convert a string to a corresponding instance of an <code>Enum</code> subclass? Seems like <code>getattr(YourEnumType, str)</code> does the job, but I'm not sure if it's safe enough.</p>
  <p>As an example, suppose I have an enum like</p>
  <pre><code>class BuildType(Enum):
      debug = 200
      release = 400
  </code></pre>
  <p>Given the string <code>'debug'</code>, how can I get <code>BuildType.debug</code> as a result?</p>