Re: [Tutor] .readlines() condensing multiple lines

2005-03-23 Thread Kent Johnson
Liam Clarke wrote: Oh right, From his email, I got the impression he was getting a list like - [[abc\rdef\rghi\r]] We really need a clarification of what is in the original file and what results he is getting. My impression is that it is mixed line endings so the result of readlines is multiple

Re: [Tutor] .readlines() condensing multiple lines

2005-03-23 Thread Mike Hall
Liam, rU worked like a charm. My previous syntax where the lines were condensing was: fOpen = file(f, r) fRead = fTmp.readlines() In this instance the size of fRead would not correspond to my line numbers. With fOpen = file(f, rU) it now does. Thanks :) On Mar 22, 2005, at 7:15 PM, Liam

Re: [Tutor] .readlines() condensing multiple lines

2005-03-23 Thread Mike Hall
On Mar 23, 2005, at 3:17 AM, Kent Johnson wrote: Anyway, Mike, it seems clear that your file has line endings in it which are not consistent with the default for your OS. If reading with universal newlines doesn't solve the problem, please let us know what OS you are running under and give more

[Tutor] .readlines() condensing multiple lines

2005-03-22 Thread Mike Hall
Unless I'm mistaken .readlines() is supposed to return a list, where each index is a line from the file that was handed to it. Well I'm finding that it's putting more than one line of my file into a single list entry, and separating them with \r. Surely there's a way to have a one to one

Re: [Tutor] .readlines() condensing multiple lines

2005-03-22 Thread Liam Clarke
From the docs - In addition to the standard fopen() values mode may be 'U' or 'rU'. If Python is built with universal newline support (the default) the file is opened as a text file, but lines may be terminated by any of '\n', the Unix end-of-line convention, '\r', the Macintosh convention or

Re: [Tutor] .readlines() condensing multiple lines

2005-03-22 Thread Kent Johnson
Liam Clarke wrote: Worse come to worse, you could always do - x = file(myFile, 'r').read() listX = x.split('\r') This will leave the \n in the strings. Reading with universal newlines is a better solution. Kent ___ Tutor maillist - Tutor@python.org

Re: [Tutor] .readlines() condensing multiple lines

2005-03-22 Thread Liam Clarke
Oh right, From his email, I got the impression he was getting a list like - [[abc\rdef\rghi\r]] On Wed, 23 Mar 2005 00:12:12 -0500, Kent Johnson [EMAIL PROTECTED] wrote: Liam Clarke wrote: Worse come to worse, you could always do - x = file(myFile, 'r').read() listX = x.split('\r')