Jeff Whitaker wrote:
> John: 'rU' apparently doesn't work for gzipped text files (at least in
> python 2.5.2). I had to change the default in back to 'r' when using
> gzip.open (r6846 in trunk).
darn -- sounds like a bug/missing feature in the gzip module. Strange ,
though, unknown flags seem to be ignored by file(), and gzip.open seems
to ignore the 'U' too, in my tests (see below).
I think having the 'U' ignored is less than optimal, but doesn't make
anything worse than it is. What problems did you have?
tests (on an OS-X system - native unix newlines):
(python 2.5.2)
>>> file('test_newlines.txt', 'rb').read()
'line 1: unix \nline 2: dos \r\nline 3: mac \rline 4: unix \n'
>>> file('test_newlines.txt', 'r').read()
'line 1: unix \nline 2: dos \r\nline 3: mac \rline 4: unix \n'
>>> file('test_newlines.txt', 'U').read()
'line 1: unix \nline 2: dos \nline 3: mac \nline 4: unix \n'
# so file() does the right thing
>>> gzip.open('test_newlines.txt.gz', 'rb').read()
'line 1: unix \nline 2: dos \r\nline 3: mac \rline 4: unix \n'
>>> gzip.open('test_newlines.txt.gz', 'r').read()
'line 1: unix \nline 2: dos \r\nline 3: mac \rline 4: unix \n'
>>> gzip.open('test_newlines.txt.gz', 'rU').read()
'line 1: unix \nline 2: dos \r\nline 3: mac \rline 4: unix \n'
# gzip.open() appears to ignore the 'U' flag -- too bad!
should we post a bug report/feature request to Python?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[email protected]
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users