title: Python: How to use a nested Enum as a default argument of the function in which it is nested?
body: <p>Is there a way to do something like this in python?</p>
  
  <pre><code>from enum import Enum, auto
  def some_func(mode = Mode.A):    
      class Mode(Enum):
          A = auto()
      print(mode == Mode.A)
  </code></pre>
  
  <p>desired outcome</p>
  
  <pre><code>&gt;&gt;&gt; some_func()
  True
  </code></pre>
  
  <p>The above snippet fails with <code>NameError: name 'Mode' is not defined</code> presumably because <code>class Mode</code> isn't defined when the interpreter reads <code>def some_func(mode = Mode.A):</code></p>
  
  <p>You can of course put the Enum outside the function but, if what I propose or something similar worked, I'd rather keep it inside. Keeping it inside encapsulates Mode where it is meant to be used, hopefully allowing <code>.</code> syntax to distinguish it from other similar <code>Mode</code> classes.</p>
  
  <p>I am aware that a lot of python code just uses strings for this purpose, not bothering with Enums. However I would like to find a solution using Enums. Enums are easier to maintain and help IDEs generate code completion etc.</p>
  
  <p><strong>Is there a nice way to make this work?</strong></p>