diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2008-01-30 20:37:03 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2008-01-30 20:37:03 +0100 |
commit | 796209acdabc1bc126e0587d552bc33ea4402048 (patch) | |
tree | 11c2f2848766a7ba6aa4b100f44949a716621a39 /src | |
parent | fc1eefd8c19d173ff4988ea7069553ff1b232881 (diff) | |
download | pyexiv2-796209acdabc1bc126e0587d552bc33ea4402048.tar.gz |
Implemented the equality comparison operator for class pyexiv2.Rational, will be useful for unit testing.
Diffstat (limited to 'src')
-rw-r--r-- | src/pyexiv2.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index b14b8a9..2816c7b 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -291,6 +291,19 @@ class Rational: self.numerator = long(numerator) self.denominator = long(denominator) + def __eq__(self, other): + """ + Compare two rational numbers for equality. + + Two rational numbers are equal if and only if their numerators are equal + and their denominators are equal. + + Keyword arguments: + other -- the rational number to compare to self for equality + """ + return ((self.numerator == other.numerator) and + (self.denominator == other.denominator)) + def __str__(self): """ Return a string representation of the rational number. |