[Python-ideas] changing sys.stdout encoding

Nick Coghlan ncoghlan at gmail.com
Wed Jun 6 07:49:16 CEST 2012


On Wed, Jun 6, 2012 at 1:28 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> For both of these cases a command-line option to initialize the
> encoding would be convenient.

Before adding yet-another-command-line-option, the cases where the
existing environment variable support can't be used from the command
line, but a new option could be, should be clearly enumerated.

$ python3
Python 3.2.1 (default, Jul 11 2011, 18:54:42)
[GCC 4.6.1 20110627 (Red Hat 4.6.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.encoding
'UTF-8'
>>>
$ PYTHONIOENCODING=latin-1 python3
Python 3.2.1 (default, Jul 11 2011, 18:54:42)
[GCC 4.6.1 20110627 (Red Hat 4.6.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.encoding
'latin-1'
>>>

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list