title: Which is the best way to check for the existence of an attribute?
body: <p>Which is a better way to check for the existence of an attribute?</p>
  
  <p><a href="https://stackoverflow.com/a/610893/647362">Jarret Hardie</a> provided this answer:</p>
  
  <pre><code>if hasattr(a, 'property'):
      a.property
  </code></pre>
  
  <p>I see that it can also be done this way:</p>
  
  <pre><code>if 'property' in a.__dict__:
      a.property
  </code></pre>
  
  <p>Is one approach typically used more than others?</p>