[I18n-sig] Pre-PEP: Proposed Python Character Model
Paul Prescod
paulp@ActiveState.com
Wed, 07 Feb 2001 11:44:05 -0800
"M.-A. Lemburg" wrote:
>
> Hooper Brian wrote:
> > ...
> > What about adding an
> > optional encoding argument to the existing open(),
> > allowing encoding to be passed to that, and using 'raw' as
> > the default format (what it does now)?
>
> This is what codecs.open() already provides.
There is a reason that Brian and I independently invented the same idea.
It's because Joe Programmer without a degree in rocket science is going
to expect it to work that way. Joe Programmer does not know what a codec
is, will not consider importing the codecs module and will have no idea
what to do with the object once they've got there hands on it.
It's a million times easier to tell a programmer: "If you expect to read
ASCII data add a third argument with the string 'ASCII', if you know
about encodings choose another one. If you know what raw binary data is,
and want to read it, here's another function."
One important part of Python philosophy is making it easy to do the
right thing and a little bit more work to do the wrong thing. Right now
we have the exact opposite situation. We make it incredibly convenient
for programmers to read data that they may consider strings or may
consider binary data into the same string type and then we complain: "Oh
geez, we can't do anything intelligent with strings because we don't
know whether the user intended them to be really strings or binary
data."
Paul Prescod