Pythonic way of reading a textfile line by line without throwing an exception

Deivys Ramirez deivys.ramirez at gmail.com
Wed Aug 29 01:49:10 CEST 2007


Hi everyone,

I'm a Python newbie but have experience programming PHP and C so i'm
not really new to programming but new to Python.

What's the "pythonic" way of reading a text file, line by line,
without throwing an exception when there's nothing to be read?

I've been trying to map my while(!eof(fp)) mindset to the file object
Python gives me when I call open() but have had no good results.

Regards,

Deivys Ramirez
Lima-Peru



More information about the Python-list mailing list