'While' question

Wojtek Walczak gminick at bzt.bzt
Thu Aug 21 18:11:41 EDT 2008


On Thu, 21 Aug 2008 18:01:25 -0400, Ben Keshet wrote:
> somehow. I use 'while 'word' not in line' to recognize words in the 
> texts. Sometimes, the files are empty, so while doesn't find 'word' and 
> runs forever. I have two questions:
> 1) how do I overcome this, and make the script skip the empty files? 
> (should I use another command?)
> 2) how do I interrupt the code without closing Python? (I have ActivePython)

Try the docs first. You need to read about 'continue' and
'break' statements: http://docs.python.org/tut/node6.html

HTH.

-- 
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/



More information about the Python-list mailing list