title: PyBind11 Global-Level Enum
body: <p>The PyBind11 documentation talks about using <code>enum</code> <a href="https://pybind11.readthedocs.io/en/stable/classes.html#enumerations-and-internal-types" rel="noreferrer">here</a>.</p>
  
  <p>The example shown assumes that the enum is embedded within a class, like so:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>struct Pet {
      enum Kind {
          Dog = 0,
          Cat
      };
  
      Pet(const std::string &amp;name, Kind type) : name(name), type(type) { }
  
      std::string name;
      Kind type;
  };
  
  py::class_&lt;Pet&gt; pet(m, "Pet");
  
  pet.def(py::init&lt;const std::string &amp;, Pet::Kind&gt;())
      .def_readwrite("name", &amp;Pet::name)
      .def_readwrite("type", &amp;Pet::type);
  
  py::enum_&lt;Pet::Kind&gt;(pet, "Kind")
      .value("Dog", Pet::Kind::Dog)
      .value("Cat", Pet::Kind::Cat)
      .export_values();
  </code></pre>
  
  <p>My situation is different. I have a global <code>enum</code> the value of which is used to alter the behaviour of several functions.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>enum ModeType {
    COMPLETE,
    PARTIAL,
    SPECIAL
  };
  
  std::vector&lt;int&gt; Munger(
    std::vector&lt;int&gt; &amp;data,
    ModeType          mode
  ){
    //...
  }
  </code></pre>
  
  <p>I have tried to register it like so:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>PYBIND11_MODULE(_mlib, m) {
    py::enum_&lt;ModeType&gt;(m, "ModeType")
      .value("COMPLETE", ModeType::COMPLETE )
      .value("PARTIAL",  ModeType::PARTIAL  )
      .value("SPECIAL",  ModeType::SPECIAL  )
      .export_values();
  
    m.def("Munger",              &amp;Munger, "TODO");
  }
  </code></pre>
  
  <p>Compilation is successful and the module loads in Python, but I do not see ModeType in the module's names.</p>
  
  <p>What can I do?</p>