aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHobson Lane <>2011-07-23 06:51:58 +0000
committerOlivier Tilloy <olivier@tilloy.net>2011-07-23 06:51:58 +0000
commit30624e7e706a5a7188e458c374c62f6cac20fc38 (patch)
treeebd0b884cb893f63b527b4e2f8f66215300020dc /src
parent606382449ece9560f9fc7b7ed1dc64a028d68cba (diff)
downloadpyexiv2-30624e7e706a5a7188e458c374c62f6cac20fc38.tar.gz
Added a __repr__ method to the Rational class.
Diffstat (limited to 'src')
-rw-r--r--src/pyexiv2/utils.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pyexiv2/utils.py b/src/pyexiv2/utils.py
index 22a05f7..b22bada 100644
--- a/src/pyexiv2/utils.py
+++ b/src/pyexiv2/utils.py
@@ -269,6 +269,17 @@ class Rational(object):
"""
return '%d/%d' % (self._numerator, self._denominator)
+ def __repr__(self):
+ """
+ Representation used when object is ouput to string for debug or array
+ content display, e.g. print([Rational(1,2),Rational(3,4)]).
+
+ :return: string representation of the object (class instance) for debugging
+ :rtype: string
+ """
+ return '%s(%d,%d)' % (self.__class__.__name__,self._numerator,self._denominator)
+
+
def is_fraction(obj):
"""