]> granicus.if.org Git - python/commitdiff
Avoid TypeError by not comparing complex numbers
authorAndrew M. Kuchling <amk@amk.ca>
Thu, 24 Apr 2003 16:59:45 +0000 (16:59 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Thu, 24 Apr 2003 16:59:45 +0000 (16:59 +0000)
Demo/classes/Rat.py

index 4fc4a1786f1f447c272d884598d2b0c65c21a1b2..9e0c05d76ff74d0d4502bb755893d2fcaab6c6f0 100755 (executable)
@@ -301,7 +301,12 @@ def test():
                print complex(i)
                print
                for j in list:
-                       print i + j, i - j, i * j, i / j, i ** j, cmp(i, j)
+                       print i + j, i - j, i * j, i / j, i ** j,
+                        if not (isinstance(i, ComplexType) or
+                                isinstance(j, ComplexType)):
+                                print cmp(i, j)
+                        print
+
 
 if __name__ == '__main__':
     test()