title: How to access an Enum's value directly as a class attribute?
body: <p>I'm learning how to use <code>Enum</code> classes in Python, and have found that whenever I need to access the actual value of the enum, I need to append the <code>.value</code> property:</p>
  
  <pre><code>from enum import Enum
  class Pets(Enum):
      DOG = "Fido"
      CAT = "Kitty"
  
  Pets.DOG # yields Pets.DOG
  Pets.DOG.value # yields Fido
  </code></pre>
  
  <p>As an exercise, I'm trying configure my <code>Enum</code> class so that I do not need to continually access that <code>value</code> property. <strong>My desired behavior is that when I call <code>Pets.DOG</code>, I get <code>Fido</code> as my value.</strong></p>
  
  <p>I'm tried to implement this with <code>__getattr_(cls, item)</code>:</p>
  
  <pre><code>class Pets(Enum):
  
      def __getattr__(self, item):
          print(f"__getattr__ called with {item}")
          return getattr(self, item).value
  
      DOG = "Fido"
      CAT = "Kitty"
  
  
  if __name__ == "__main__":
  
      pets = Pets()
      pets.DOG
  </code></pre>
  
  <p>However, I receive a <code>RecursionError: maximum recursion depth exceeded while calling a Python object</code>, and <code>item</code> is a string value of <code>_value_</code>. I'm not quite understanding why this behavior is happening - is this built in Python behavior, or because I am using a special class <code>Enum</code>?</p>
  
  <p>I did take a look at a similar SO post, but the solutions there were to use another module (<code>inspect</code>), or access the <code>__dict__</code> or <code>dir()</code> and parse it yourself with a combination of conditionals or regex. Is there a better way to access the underlying <code>Enum</code>'s value?</p>