[Python-ideas] changing sys.stdout encoding

Masklinn masklinn at masklinn.net
Tue Aug 7 12:35:38 CEST 2012


On 2012-06-06, at 07:49 , Nick Coghlan wrote:

> 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'
>>>> 

LC_CTYPE also works, and is not specific to Python.


More information about the Python-ideas mailing list