[Tutor] != -1: versus == 1

pedro pedrooconnell at gmail.com
Fri Jul 17 18:26:42 CEST 2009


Hi I have been trying to understand a python script and I keep coming 
across this kind of structure
that says "If it is not equal to negative one"

################################
for line in theLines:
    if line.find("Source Height") != -1:
#etc...
###################################

Is there some special reason for this. Why not just write "If it is 
equal to one"

#########################
for line in theLines:
    if line.find("Source Height") == 1:
#etc...
###################################
Pete




More information about the Tutor mailing list