[Python-ideas] Normalized Python

Chris Angelico rosuav at gmail.com
Wed Jan 29 18:36:33 CET 2014


On Thu, Jan 30, 2014 at 4:24 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
> Note that when the other side is a Windows console, what it _really_ wants is for you not to use stdio, but to instead use the separate UTF-16-specific console APIs.
>
> Fitting this into Python 3's cross-platform io model is a bit challenging, and not yet done, but certainly doable. (It's been discussed multiple times, both on this list and elsewhere.)
>

In the theoretical ideal, all that should be buried within the
definition of the print function (or what it calls on). I should be
able to write a program that says:

print("Copyright © 2014 My Name")

even if my name includes non-ASCII, even non-BMP, characters; and that
program should produce that output in whatever way is appropriate to
the platform. (If it's running on a printer, that should produce a
hard copy.) Now, maybe that ideal can't be attained, due to some
platforms' limitations or stupidity, and clean code is of value too,
but certainly the notion of "write a Unicode string to the most
obvious place of output" is one that ought *conceptually* to be
supported equally on all platforms, without my having to figure out
one from another.

Obviously if your terminal expects one encoding but announces another,
there's going to be a mess. The theoretical ideal works only when
negotiations are done properly. But again, that's outside of Python;
and if the next version of SomeWeirdOS introduces a new means of
announcing its console encoding, it should simply be a matter of
coding that into Python, *not* into every single script.

ChrisA


More information about the Python-ideas mailing list