[Pythonmac-SIG] Universal newline support in file.readlines()?

Larry Meyn Larry.A.Meyn@nasa.gov
Thu, 20 Mar 2003 15:25:36 -0800


--Apple-Mail-26--971423385
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Jack,

I'd forgotten about the 'U' option from discussions long ago and I 
although I read the docs on file objects, I neglected to read the docs 
on the file() & open() functions.  Many thanks to you and Chris for 
re-educating me.  It would have been nice if 'U' was a default, as I 
did have to put in a the following code to assure the code would work 
in Python 2.2.

	try:
		f = open(filename,'U')
	except:
		f = open(filename)

Again, this is mainly a transition annoyance and not an issue in the 
long term.

Larry

On Thursday, March 20, 2003, at 02:01  PM, Jack Jansen wrote:

> If you open a file with file = open(filename, 'U') then all methods to 
> read (read(), readline(), readlines(), xreadlines()) should return 
> '\n' for a newline, no matter what is used in the file.
>
> If you're seeing something different this is definitely a bug,
Larry Meyn
Aerospace Operations Modeling Office

M/S 210-10                      Phone:  (650) 604-5038
NASA Ames Research Center       Fax:    (650) 604-0222
Moffett Field, CA 94035-1000    E-mail: Larry.A.Meyn@nasa.gov
                                 E-Fax:  (425) 944-5526 sent via e-mail


--Apple-Mail-26--971423385
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

Jack,


I'd forgotten about the 'U' option from discussions long ago and I
although I read the docs on file objects, I neglected to read the docs
on the file() & open() functions.  Many thanks to you and Chris for
re-educating me.  It would have been nice if 'U' was a default, as I
did have to put in a the following code to assure the code would work
in Python 2.2.  


	try:

		f = open(filename,'U')

	except:

		f = open(filename)


Again, this is mainly a transition annoyance and not an issue in the
long term.


Larry


On Thursday, March 20, 2003, at 02:01  PM, Jack Jansen wrote:


<excerpt>If you open a file with file = open(filename, 'U') then all
methods to read (read(), readline(), readlines(), xreadlines()) should
return '\n' for a newline, no matter what is used in the file.


If you're seeing something different this is definitely a bug,

</excerpt><fontfamily><param>Courier</param>Larry Meyn

Aerospace Operations Modeling Office


M/S 210-10                      Phone:  (650) 604-5038

NASA Ames Research Center       Fax:    (650) 604-0222

Moffett Field, CA 94035-1000    E-mail: Larry.A.Meyn@nasa.gov

                                E-Fax:  (425) 944-5526 sent via e-mail

</fontfamily>


--Apple-Mail-26--971423385--