[Tutor] Finding word in file
Joseph Quigley
cpu.crazy at gmail.com
Wed May 18 23:55:47 CEST 2005
>What are you trying?
>You could simply read through the file line by line using the string
>search methods. Store the previous 2 lines then when found print the
>previous two lines, the current line and then read and print the next
>two lines. There are more sophisticated methods but that should do...
How? Does your tutorial cover that (i don't remember it doing so)?
>You need to catch the error not state it.
OK
>try: f = file(....)
>except IOError: print 'file not....'
Did that, IO Error handling works great now. Thanks
JQ
More information about the Tutor
mailing list