[Pythonmac-SIG] Reading big text files

Joseph J. Strout joe@strout.net
Tue, 8 Jun 1999 10:12:04 -0700


>>   if x[:9] == "%%Pages: ":
>>    print "Found", x[9:-1], "pages!"

Note that you don't need the -1 here, the standard idiom would be x[9:].

>> Anyone an idea how I can handle this problem. I also have some problems with
>> the different line-ending style from the different platforms. How should I
>> handle this??

What sort of problems?  Mac Python does line ending conversion for you
automagically when you open a file in text mode, at least if you use
readline().  Anyway, applying a string.strip() to each line certainly does
the trick.

Cheers,
-- Joe
,------------------------------------------------------------------.
|    Joseph J. Strout           Biocomputing -- The Salk Institute |
|    joe@strout.net             http://www.strout.net              |
`------------------------------------------------------------------'