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

B

bor

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
by
an else... etc

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

However...

class C:
def __init__(self): pass

X=C()
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
I'd
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,498
Latest member
log5Sshell/alfa5

Latest Threads

Top