On 2007-12-14, Christian Heimes wrote: > Mark Summerfield wrote: > > Hi, > > > > I was wondering if it is yet known what the right way to open text files > > in P3K will be? > > > > According to the docs the signature for open() is: > > > > open(filename[, mode[, bufsize]]) > > The docs must be outdated. open() accepts more arguments: > > open(file, mode='r', buffering=None, encoding=None, errors=None, > newline=None, closefd=True) > > > Is that going to stay the same and default to UTF-8 if "b" is not in the > > mode (or if no mode is specified) and bytes if "b" is present? > > The new IO library is using UTF-8 as default encoding for text mode > unless a different encoding is given. The open() function and the IO > streams are much closer to the codecs package. > > help(open) isn't very helpful in 3.0a2 and earlier. I fixed the doc > string shortly after the release. import io; help(io.open) gives you the > real open function. Please note that the IO library is mostly written in > Python, see Lib/io.py
The API is exactly what I'd hoped it would be:-) (So is there any need for codecs.open(), apart from backwards compatibility?) I've now updated library/functions.rst (change 59499) to reflect your io.open() docs. If you had the time you might want to check that I haven't said anything untrue! Unfortunately io.open() doesn't say what errors=None means. I hope it means 'strict', but whatever it means, I'd like to specify the meaning in the docs. Thanks! -- Mark Summerfield, Qtrac Ltd., www.qtrac.eu _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com