Newby: how to transform text into lines of text

Andreas Waldenburger geekmail at usenot.de
Mon Jan 26 10:10:11 EST 2009


On 26 Jan 2009 14:51:33 GMT Marc 'BlackJack' Rintsch <bj_666 at gmx.net>
wrote:

> On Mon, 26 Jan 2009 12:22:18 +0000, Sion Arrowsmith wrote:
> 
> > content = a.readlines()
> > 
> > (Just because we can now write "for line in file" doesn't mean that
> > readlines() is *totally* redundant.)
> 
> But ``content = list(a)`` is shorter.  :-)
> 
But much less clear, wouldn't you say?

content is now what? A list of lines? Characters? Bytes? I-Nodes?
Dates? Granted, it can be inferred from the fact that a file is its
own iterator over its lines, but that is a mental step that readlines()
frees you from doing.

My ~0.0154 €.

/W

-- 
My real email address is constructed by swapping the domain with the
recipient (local part).




More information about the Python-list mailing list