Unicode, stdout, and stderr
frank at chagford.com
Tue Jul 22 09:06:15 CEST 2014
"Lele Gaifax" <lele at metapensiero.it> wrote in message
news:87lhrl28ie.fsf at nautilus.nautilus...
> "Frank Millman" <frank at chagford.com> writes:
>> Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
>> tel)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> x = '\u2119'
>>>>> x # this uses stderr
>>>>> print(x) # this uses stdout
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "C:\Python34\lib\encodings\cp437.py", line 19, in encode
>> return codecs.charmap_encode(input,self.errors,encoding_map)
>> UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in
>> 0: character maps to <undefined>
> No, both statements actually emit noise on the standard output, but the
> former prints the *repr* of the string, the latter tries to encode it to
> CP437, which you console seems to be using.
Thanks, Lele, but I don't think that is quite right - see my separate
response to Steven
More information about the Python-list