string find mystery
John Yeung
gallium.arsenide at gmail.com
Thu Sep 3 01:53:19 EDT 2009
On Sep 3, 1:45 am, Sean DiZazzo <half.ital... at gmail.com> wrote:
> string.find() returns the index at which the given word is found
> within the string. If the string is not found it returns -1. So, no
> matter what you do, string.find() will evaluate to "True"
It will evaluate as false if the substring is found at the beginning
(position 0).
> You could use it like this: if file_str.find("Geometry") != -1:
>
> but you probably want to use: if "Geometry" in file_str:
This is good advice, however.
John
More information about the Python-list
mailing list