"Frank Millman" <[email protected]> writes:
> "Steven D'Aprano" <[email protected]> wrote in message
> news:[email protected]...
>> I would be surprised if that were the case, but I don't have a Windows
>> box to test it. Try this:
>>
>>
>> import sys
>> print(x, file=sys.stderr) # I expect this will fail
>
> It does not fail.
Effectively it does not, but for some reason it actually print the
repr() of the string.
>> print(repr(x), file=sys.stdout) # I expect this will succeed
>>
>
> It fails.
This surprises me as well, why does it fail here?
>>> repr('\u2119')
"'\u2119'"
>>> print(repr('\u2119'))
Traceback ... UnicodeEncodeError ...
On GNU/Linux, I get:
>>> repr('\u2119')
"'ℙ'"
>>> print(repr('\u2119'))
'ℙ'
Uhm, it must be related to the fact that on Py3 the repr() of something
is a unicode object too, so the output machinery tries to encode it to
the output encoding.... Still, I miss the difference between stdout and
stderr (both are cp437, accordingly to sys.xxx.encoding).
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email protected] | -- Fortunato Depero, 1929.
--
https://mail.python.org/mailman/listinfo/python-list