josiah.carlson at gmail.com
Tue Jan 20 02:46:27 CET 2009
On Sun, Jan 18, 2009 at 2:41 PM, Leif Walsh <leif.walsh at gmail.com> wrote:
> On Wed, Jan 14, 2009 at 2:12 AM, Carl Johnson <carl at carlsensei.com> wrote:
>> From the department of doomed ideas:
>> data = f.read() with open("file.txt") as f
> "Who do you think we are, Ruby?"
> Just kidding, but -1.
I always preferred:
data = open("file.txt").read()
Which works all the way back as far as I can remember.
And as for:
strippedLines = [sline for line in lines with line.strip() as sline if sline]
strippedLines = [sline for sline in (line.strip() for line in lines) if sline]
The request gets a big fat -1 from me.
More information about the Python-ideas