The rap against "while True:" loops
Xavier Ho
contact at xavierho.com
Mon Oct 12 09:47:23 EDT 2009
On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia <kyrie at uh.cu> wrote:
> Actually, in python, this works even better:
>
> for lin in iter(file_object.readline, ""):
> ... do something with lin
>
>
What about ....
>>> with open(path_string) as f:
>>> for line in f:
>>> # do something
Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091012/a3098980/attachment-0001.html>
More information about the Python-list
mailing list