[Python-Dev] str object going in Py3K
Nick Coghlan
ncoghlan at gmail.com
Wed Feb 15 11:09:33 CET 2006
Guido van Rossum wrote:
> But somehow I still like the 'open' verb. It has a long and rich
> tradition. And it also nicely conveys that it is a factory function
> which may return objects of different types (though similar in API)
> based upon either additional arguments (e.g. buffering) or the
> environment (e.g. encodings) or even inspection of the file being
> opened.
If we went with longer names, a slight variation on the opentext/openbinary
idea would be to use opentext and opendata.
That is, "give me something that looks like a text file (it contains
characters)", or "give me something that looks like a data file (it contains
bytes)".
"opentext" would map to "codecs.open" (that is, accepting an encoding argument)
"opendata" would map to the standard "open", but with the 'b' in the mode
string added automatically.
So the mode choices common to both would be:
'r'/'w'/'a' - read/write/append (default 'r')
''/'+' - update (IOError if file does not already exist) (default '')
opentext would allow the additional option:
''/'U' - universal newlines (default '')
Neither of them would accept a 'b' in the mode string.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list