-
-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print string instead of escaped unicode for some unprintable unicode #109443
Comments
|
This is the difference between |
|
There's a need that copy unicode strings to other programs for future processes, so python is there to print those characters. Neither seems currently Python has no ability to print objects containing uncommon Unicode strings without escaping them, except manually iterate over every inside object and manually print it. |
|
It may be a special and less common use case, |
|
You have not described how your feature would work. Please do so. |
In [1]: print('\ue011')
In [2]: str('\ue011')
Out[2]: '\ue011'
In [3]: print({'\ue011'})
{'\ue011'} # it's still str(), not repr() inside the set or dict.
In [4]: repr('\ue011')
Out[4]: "'\\ue011'"so now the only way to print those characters in Python is it's very helpful displaying escaped Unicode point in programing, but sometimes ppl want print the real character as well like font processing. |
|
Some of those are being printed by |
|
You can just verify it by yourself. It's the same result, no matter in pure python REPL, or run with |
|
Interactive CPython and anything the imitates it prints the repl() of the object, even if it is a string. Use print() for the str(). Whether an unprintable character shows as a box or blank depends on the OS, display device, and maybe the current font, not python. |
Right. The use case intends to print a box or blank, but cPython only can print the escaped Unicode code(e.g. '\u3000' not ' ') if the string is not directly as argument passed to the 'print' (e.g. say in a object), even with 'python test.py' instead of repl env. # python test.py
print('\u3000')
print({'\u3000'})prints rather than the expected (with a new option) |
Feature or enhancement
Proposal:
I need to copy the or to other programs for searching and etc.
but python seems to always escape some unprintable characters, even set sys.displayhook(None).
The print seems to work, but it's inconvenient to iterate over every object for a nested object to print.
The pprint seems not to work at all.
The default str seems not easy to modify. And I haven't found any document about this.
I wonder how to change this behavior of Python on demand.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: