[I18n-sig] Modified open() builtin (Re: Python Character Model)

Guido van Rossum guido@digicool.com
Sat, 10 Feb 2001 17:23:54 -0500

> Paul Prescod wrote:
> > 
> > At the bottom of one of my messages I proposed that we insert it as the
> > second argument. Although the encoding and mode are both strings there
> > is no syntactic overlap between [rwa][+]?[tb]+ and the set of existent
> > or proposed encodings. If we merely outlaw encodings with that name then
> > we can quickly figure out whether the second argument is a mode or an
> > encoding. So the documented syntax would be
> > 
> > open(filename, encoding, [[mode], bytes])
> > 
> > And the documentation would say:
> > 
> > "There is an obsolete variant that does not require an encoding string.
> > This may cause a warning in future versions of Python and be removed
> > sometime after that."

I am appalled at this lack of respect for existing conventions, when a
simple and obvious alternative (see below) is easily available.  I
will have a hard time not to take this into account when I finally get
to reading up on your proposals.

> Any reason why we cannot use a keyword argument for encoding
> and put it at the end of the argument list ? The result is:
> 1. no ambiguity
> 2. backward compatibility
> 3. good visibility of what the argument stands for (without having
>    to look up the manual for e.g. the meaning of 'mbcs')

Of course this is what should be done when adding a new argument to an
existing API.

--Guido van Rossum (home page: http://www.python.org/~guido/)