2009/7/17 pedro <[email protected]>:
> ################################
> 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"

Yes, str.find() returns -1 on failure. See below the documentation for
str.find()

 |  find(...)
 |      S.find(sub [,start [,end]]) -> int
 |
 |      Return the lowest index in S where substring sub is found,
 |      such that sub is contained within s[start:end].  Optional
 |      arguments start and end are interpreted as in slice notation.
 |
 |      Return -1 on failure.

Idle example:

>>> teststr = 'a'
>>> teststr.find('a')
0
>>> teststr.find('b')
-1

Greets
Sander
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to