From: Andrew M. Kuchling Date: Thu, 24 Apr 2003 16:59:45 +0000 (+0000) Subject: Avoid TypeError by not comparing complex numbers X-Git-Tag: v2.3c1~1026 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64b3c830d44aaeac8de85067113b03bc62a92957;p=python Avoid TypeError by not comparing complex numbers --- diff --git a/Demo/classes/Rat.py b/Demo/classes/Rat.py index 4fc4a1786f..9e0c05d76f 100755 --- a/Demo/classes/Rat.py +++ b/Demo/classes/Rat.py @@ -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()