From: Jérémie Galarneau Date: Thu, 23 Nov 2017 19:41:25 +0000 (-0500) Subject: Implement __repr__ instead of __str__ for _NumericField X-Git-Tag: v2.0.0-pre5~355 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=e100fef0a55b507996837f74d1cd2b34c9f8be79 Implement __repr__ instead of __str__ for _NumericField __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 --- 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):