[Pythonmac-SIG] Universal newline support in file.readlines()?
Jack Jansen
Jack.Jansen@oratrix.com
Thu, 20 Mar 2003 23:01:45 +0100
On donderdag, maa 20, 2003, at 17:38 Europe/Amsterdam, Larry Meyn wrote:
> I use the readlines() method for file objects in many of my scripts.
> After switching to Python 2.3 (specifically the framework build
> 2.3.a2+ from the kitchen sink distro) readlines() now seems to
> require that files have Unix newlines instead of Mac newlines. This
> is really only an annoyance for me, since I probably won't switch back
> to earlier versions that require Mac newlines, but it could be a
> problem for people that do switch back and forth. Is there a
> performance issue in supporting universal newlines in the readlines()?
> Or am I missing something that makes universal newlines work in
> readlines()?
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,
--
- Jack Jansen <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma
Goldman -