From ac7e2dc617360c61ee46cc1b3dd275d1d00aae03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 23 Nov 2017 11:56:46 -0500 Subject: [PATCH] Implement __repr__ for _StructureField MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Philippe Proulx Reviewed-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- bindings/python/bt2/bt2/fields.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/python/bt2/bt2/fields.py b/bindings/python/bt2/bt2/fields.py index 2f910635..c79bb899 100644 --- a/bindings/python/bt2/bt2/fields.py +++ b/bindings/python/bt2/bt2/fields.py @@ -526,6 +526,10 @@ class _StructureField(_ContainerField, collections.abc.MutableMapping): value = property(fset=_set_value) + def __repr__(self): + items = ['{}: {}'.format(repr(k), repr(v)) for k, v in self.items()] + return '{{{}}}'.format(', '.join(items)) + class _VariantField(_Field): _NAME = 'Variant' -- 2.34.1