[I18n-sig] Modified open() builtin (Re: Python Character Model)
M.-A. Lemburg
mal@lemburg.com
Tue, 13 Feb 2001 09:01:48 +0100
Paul Prescod wrote:
>
> Tim Peters wrote:
> >
> > [Paul Prescod]
> > > It has nothing to do with awareness of il8n issues. The fundamental
> > > question is whether you expect to get text back from a read() or binary.
> >
> > C already addresses that distinction ("r" vs "rb" open modes).
>
> Python is documented as only using the distinction to handle line ends.
> We want to create totally different object types based on the flag.
Two things:
1. the difference between "r" and "rb" only exists on some non-Unix
platforms (e.g. Windows)
2. the codec decides which type of object to return for .read()
-- this has nothing to do with the file mode, but instead is
dependent on the encoding used, e.g. encoding='binary' would
return a binary string, encoding='ascii' results in Unicode
and encoding='pil-image' could produce a PIL image object...
Paul, you ought to write up a PEP about this subject discussing
all the different issues with adding more optional parameters
(encoding and errors, possibly more) to open().
It should also include a discussion about the
implications using an encoding would have w/r to the applications
relying on getting a real file object from the builtin open().
--
Marc-Andre Lemburg
______________________________________________________________________
Company: http://www.egenix.com/
Consulting: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/