[Python-ideas] changing sys.stdout encoding (original) (raw)

Rurpy rurpy at yahoo.com
Wed Jun 6 08:14:26 CEST 2012


On 06/05/2012 11:49 PM, Nick Coghlan wrote:

On Wed, Jun 6, 2012 at 1:28 PM, Stephen J. Turnbull <stephen-Sn97VrDLz2sdnm+yROfE0A at public.gmane.org> wrote:

For both of these cases a command-line option to initialize the encoding would be convenient.

A Python interpreter command line option? That would not particularly help my use case much.

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'

I don't think that works on Windows.



More information about the Python-ideas mailing list