From: Marc Schink Date: Fri, 29 Mar 2024 12:41:40 +0000 (+0100) Subject: bindings/python: Add __repr__() to 'Channel' class X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6b0093a43998e2f0aead87313f77dad75aa524ca;p=libsigrok.git bindings/python: Add __repr__() to 'Channel' class The following lines show the class string representation before and after this patch: *' at 0x7fdf4b29ff00> > Channel (type=ChannelType.LOGIC, name='D0', index=0, enabled=True) Signed-off-by: Marc Schink --- diff --git a/bindings/python/sigrok/core/classes.i b/bindings/python/sigrok/core/classes.i index efcd763e..46672a39 100644 --- a/bindings/python/sigrok/core/classes.i +++ b/bindings/python/sigrok/core/classes.i @@ -614,4 +614,13 @@ std::map dict_to_map_options(PyObject *dict, Context.create_logic_packet = _Context_create_logic_packet } +%extend sigrok::Channel +{ +%pythoncode +{ + def __repr__(self): + return _class_attribute_repr(self, ['type', 'name', 'index', 'enabled']) +} +} + %include "doc_end.i"