Commit 8456a4dc authored by Wenzel Jakob's avatar Wenzel Jakob
Browse files

minor enum_ improvement (use __repr__ instead of __str__)

parent bcd3182f
......@@ -813,7 +813,7 @@ public:
enum_(object &scope, const char *name, const char *doc = nullptr)
: class_<Type>(scope, name, doc), m_parent(scope) {
auto entries = new std::unordered_map<int, const char *>();
this->def("__str__", [name, entries](Type value) -> std::string {
this->def("__repr__", [name, entries](Type value) -> std::string {
auto it = entries->find((int) value);
return std::string(name) + "." +
((it == entries->end()) ? std::string("???")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment