On Sun, Jan 22, 2012 at 8:50 AM, Rick Johnson
<[email protected]>wrote:
>
> What does Python do when presented with this code?
>
> py> [line.strip('\n') for line in f.readlines()]
>
> If Python reads all the file lines first and THEN iterates AGAIN to do
> the strip; we are driving a Fred flintstone mobile. If however Python
> strips each line of the lines passed into readlines in one fell swoop,
> we made the correct choice.
>
> Which is it Pythonistas? Which is it?
>
>
Two iterations. And since that is the only possible way to do this, you
are correct, the language is terribly archaic. I suggest you switch to
Ruby ASAP.
--
http://mail.python.org/mailman/listinfo/python-list