<SNIP>
>
>
> If you really have to handle the case where there is a final key with no
> data, then you'll have to detect that case, and make up the data
> separately. That could be done with a try block, but this is probably
> clearer:
>
> rawlines = object.readlines()
> if len(rawlines) %2 != 0:
> rawlines += "" #add an extra line
Oops, that should have been
rawlines.append("") or maybe rawlines.append("\n")
> lines = iter(rawlines)
>
> for keyline in lines:
> linedata = lines.next()
> for word in searches:
> if word in keyline:
> print word, "-->", linedata
>
>
--
DaveA
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor