]> sigrok.org Git - libsigrok.git/commitdiff
bindings/python: Add __repr__() to 'Driver' class
authorMarc Schink <redacted>
Fri, 29 Mar 2024 12:41:19 +0000 (13:41 +0100)
committerSoeren Apel <redacted>
Thu, 20 Nov 2025 18:01:23 +0000 (19:01 +0100)
The following lines show the class string representation before and
after this patch:

<sigrok.core.classes.Driver; proxy of <Swig Object of type 'std::shared_ptr< sigrok::Driver > *' at 0x7fdf4b29cff0> >
Driver (name='demo', long_name='Demo driver and pattern generator')

Signed-off-by: Marc Schink <redacted>
bindings/python/sigrok/core/classes.i

index 325983d7f943a1325211440099da9f1cc87d8aa4..efcd763e4d9aab52702d78fa1c75c7a68306d7c0 100644 (file)
@@ -494,6 +494,12 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
 
         return $self->scan(options);
     }
+
+%pythoncode
+{
+    def __repr__(self):
+        return _class_attribute_repr(self, ['name', 'long_name'])
+}
 }
 
 %pythoncode