From e100fef0a55b507996837f74d1cd2b34c9f8be79 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 23 Nov 2017 14:41:25 -0500 Subject: [PATCH] Implement __repr__ instead of __str__ for _NumericField MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit __repr__ provides a generic fallback for __str__ and, in the case of IntegerFields the representation is both human readable and unambiguous. 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, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/bt2/bt2/fields.py b/bindings/python/bt2/bt2/fields.py index e24bf5f2..2e2796c9 100644 --- a/bindings/python/bt2/bt2/fields.py +++ b/bindings/python/bt2/bt2/fields.py @@ -110,8 +110,8 @@ class _NumericField(_Field): def __float__(self): return float(self._value) - def __str__(self): - return str(self._value) + def __repr__(self): + return repr(self._value) def __lt__(self, other): if not isinstance(other, numbers.Number): -- 2.34.1