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

Paul Prescod paulp@ActiveState.com
Sun, 11 Feb 2001 14:35:42 -0800

"M.-A. Lemburg" wrote:
> [Paul, it would help if you wouldn't always remove important parts
>  of the quoted messages... people who don't read the whole thread
>  won't have a chance to follow up]

I think we have different interpretations of important...

> Paul Prescod wrote:
> >
> > ...
> > There is an important reason that we did not use a keyword argument.
> >
> > We (at least some subset of the people in the i18n-sig) want every
> > single new instance of the "open" function to declare an encoding.
> This doesn't make sense: not all uses of open() target text
> information. What encoding information would you put into an
> open() which wants to read a JPEG image from a file ?

"binary" or "raw"

> f = open(filename, 'w', encoding='mbcs')
> There's a little more typing required, but the readability is
> unbeatable...

Why not go all the way:

 f = open(filename=filename, mode='w', encoding='mbcs')

Keyword attributes are great for optional parameters. I don't see
encoding as optional. Anyhow, I like Fredrick's idea of extending the
mode string.

 Paul Prescod