Fw: How does compare work?..Of no help, but...

bor borkxorfoo at hotmail.com
Tue Jan 27 10:34:42 CET 2004

of no help, so just <snip> if you hate that sort of thing...

 if 2 > '1' : print "greater"
 else       : print "less_or_equal"

   prints  less_or_equal

 As it should, because the condition 2>'1' is not true..
 Give a machine a conditional statement that doesn't return true, followed
 an else... etc

 Under most circumstances, python is fairly logical. In this case, too.


 class C:
      def __init__(self): pass

 if 2 > X : print "greater"

    prints  greater

 Now *here* I see exactly what you're saying.
 I'd noticed this slight oddness too..
 First example doesn't really exhibit the behaviour, but this one bothers
 slightly. I'm not really on top of the technical stuff about python, but
 had all sorts of obvious thoughts about this one like could the comparison
 be taking
 an instance to have 'no' numerical value ie 'none' when using some
 particular comparison method?

 I'd be interested to know this one myself...


 M. Harris
 Sr Developer
 DNM, Inc.

More information about the Python-list mailing list