the stupid encoding problem to stdout

Ben Finney ben+python at benfinney.id.au
Thu Jun 9 21:45:51 EDT 2011


Sérgio Monteiro Basto <sergiomb at sapo.pt> writes:

> Nobody wrote:
>
> >> Exactly the opposite , if python don't know the encoding should not
> >> try decode to ASCII.

Are you advocating that Python should refuse to write characters unless
the encoding is specified? I could sympathise with that, but currently
that's not what Python does; instead it defaults to the ASCII codec.

> > What should it decode to, then?
>
> UTF-8, as in tty

But when you explicitly redirect to a file, it's *not* going to a TTY.
It's going to a file whose encoding isn't known unless you specify it.

-- 
 \     “Reality must take precedence over public relations, for nature |
  `\                            cannot be fooled.” —Richard P. Feynman |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list