From 71c8a06e0d7b3aefdc654d4654501fa7aa234e8a Mon Sep 17 00:00:00 2001 From: Michael Schindler Date: Tue, 6 Mar 2007 16:58:40 +0000 Subject: [PATCH] added __truediv__ methods according to PEP 238 -- this should fix bug 1648534 git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@2863 069f4177-920e-0410-937b-c2a4a81bcd90 --- CHANGES | 1 + pyx/graph/axis/tick.py | 2 ++ pyx/normpath.py | 2 +- pyx/unit.py | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index bb8bea46..a9a4e92c 100644 --- a/CHANGES +++ b/CHANGES @@ -92,6 +92,7 @@ TODO: 0.10 (2006/XX/XX): + - added __truediv__ methods according to PEP 238 - color module: - renamed: palette->gradient, functionpalette->functiongradient, linearpalette->lineargradient - new class palette representing a discrete ordered list of colors diff --git a/pyx/graph/axis/tick.py b/pyx/graph/axis/tick.py index 4d07c9d4..dc59ac3f 100644 --- a/pyx/graph/axis/tick.py +++ b/pyx/graph/axis/tick.py @@ -180,6 +180,8 @@ class rational: def __div__(self, other): return rational((self.num * other.denom, self.denom * other.num)) + __truediv__ = __div__ + def __idiv__(self, other): self.num *= other.denom self.denom *= other.num diff --git a/pyx/normpath.py b/pyx/normpath.py index 3959b4f7..5811534d 100644 --- a/pyx/normpath.py +++ b/pyx/normpath.py @@ -82,7 +82,7 @@ class _invalid: def invalid2(self, other): self.invalid1() - __cmp__ = __add__ = __iadd__ = __sub__ = __isub__ = __mul__ = __imul__ = __div__ = __idiv__ = invalid2 + __cmp__ = __add__ = __iadd__ = __sub__ = __isub__ = __mul__ = __imul__ = __div__ = __truediv__ = __idiv__ = invalid2 invalid = _invalid() diff --git a/pyx/unit.py b/pyx/unit.py index ce46a739..932eaabb 100644 --- a/pyx/unit.py +++ b/pyx/unit.py @@ -134,6 +134,8 @@ class length: result.x = self.x / divisor return result + __truediv__ = __div__ + def __add__(self, other): # convert to length if necessary if not isinstance(other, length): -- 2.11.4.GIT