Steven D'Aprano <[email protected]> added the comment:
By the way, there is no need to use the u'' prefix on strings in Python 3.
Unfortunately, I think this is a case where pprint doesn't meet your
expectations. pprint is designed to print the repr of a string, while regular
print prints the human-visible str:
>>> print(repr('\240 hello'))
'\xa0 hello'
>>> print('\240 hello')
hello
Its not just non-breaking space, it also includes ASCII characters:
>>> print(repr('\01 hello'))
'\x01 hello'
>>> print('\01 hello')
hello
>>> pprint.pprint('\01 hello')
'\x01 hello'
So this is intentional behaviour, not a bug. If you want to change the
behaviour, it will probably require a re-design of the way strings are printed
by the pprint module.
----------
nosy: +steven.daprano
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42852>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com