From: Martin Ling Date: Sun, 3 Jan 2016 22:22:57 +0000 (+0000) Subject: python: Provide sensible __str__ and __repr__ functions for enum values. X-Git-Tag: libsigrok-0.4.0~40 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c61e208d26325c38c9c928b00890a70f55633ddf;p=libsigrok.git python: Provide sensible __str__ and __repr__ functions for enum values. This fixes bug #668. --- 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):