]> sigrok.org Git - libsigrok.git/commitdiff
python: Provide sensible __str__ and __repr__ functions for enum values.
authorMartin Ling <redacted>
Sun, 3 Jan 2016 22:22:57 +0000 (22:22 +0000)
committerUwe Hermann <redacted>
Mon, 4 Jan 2016 19:49:35 +0000 (20:49 +0100)
This fixes bug #668.

bindings/python/sigrok/core/classes.i

index 01201bd3d7e9ae5a63f2369595eb79c334f1d0f0..2afd9cf131ed6ae7f7977dce357ae881fa4b9a66 100644 (file)
@@ -426,6 +426,16 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
     return (long) $self;
   }
 
+  std::string __str__()
+  {
+    return $self->name();
+  }
+
+  std::string __repr__()
+  {
+    return "Class." + $self->name();
+  }
+
 %pythoncode
 {
   def __eq__(self, other):