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-Url: http://drtracing.org/?a=commitdiff_plain;h=5abb9e3309c1aa2b622daebd9bea9da67a6554b8;p=deliverable%2Fbabeltrace.git 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 e24bf5f27..2e2796c90 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):