Implement __repr__ instead of __str__ for _NumericField
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 23 Nov 2017 19:41:25 +0000 (14:41 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 6 Dec 2017 15:51:27 +0000 (10:51 -0500)
__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 <eeppeliteloop@gmail.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bindings/python/bt2/bt2/fields.py

index e24bf5f27128984979b83e216ea15fafc357abdc..2e2796c901c127b8b60ad3287f18fc60db802948 100644 (file)
@@ -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):
This page took 0.025676 seconds and 4 git commands to generate.