From c61e208d26325c38c9c928b00890a70f55633ddf Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sun, 3 Jan 2016 22:22:57 +0000 Subject: [PATCH] python: Provide sensible __str__ and __repr__ functions for enum values. This fixes bug #668. --- bindings/python/sigrok/core/classes.i | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bindings/python/sigrok/core/classes.i b/bindings/python/sigrok/core/classes.i index 01201bd3..2afd9cf1 100644 --- a/bindings/python/sigrok/core/classes.i +++ b/bindings/python/sigrok/core/classes.i @@ -426,6 +426,16 @@ std::map 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):