When a function is defined in python, triple quotes represent docstring.
But Asian characters used in docstring are not properly displayed on IDLE for MacOS. They are displayed as a unicode string like '\uc778\uc0ac\ud569\ub2c8\ub2e4'.
On Windows or Linux, they are properly displayed. However, on Terminal shell in MacOS, the docstring made up of Asian characters are properly displayed. What the he**.
I think there may be a bug in tcl/tk. What should I do to represent Asian strings for docstring? I'm programming in python 3.6.3.
Thanks, everyone.
Asked
Active
Viewed 359 times
0

albert
- 1
- 1
-
Triple quotes are only needed for multi-line docstrings. Aside from that, what do you see when displaying a docstring? BMP (`\unnnn') chars should either display or be represented by a substitute char. In any case, this is controlled by tk interacting with the OS. What tcl/tk are you using? `Help` => `About IDLE` will show you. If you use the python.exe binary from python.org, you should use the latest 8.5.x tcl/tk available from ActiveState. See `https://www.python.org/download/mac/tcltk/`. – Terry Jan Reedy Nov 26 '17 at 22:19
-
Thank you, Terry. I installed latest version of ActiveTcl. But Python 3.6.3 doesn't recognize Tcl/Tk. On IDLE, the following message still appears. WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. – albert Nov 27 '17 at 03:32
-
All I can say is to **carefully** re-read the instructions on the page above about how Python find a tcl/tk. I do not have a Mac. – Terry Jan Reedy Nov 28 '17 at 06:11
-
Thank you. But what I'm telling you is Python can't recognize ActiveState's latest version of Tcl, 8.6.6, though it has been installed properly. I reverted it to an older version, 8.5.18. So the problem I said remains unsolved. Anyway, thank you again. – albert Nov 28 '17 at 17:55
-
I said above 'you should use the latest 8.5.x tcl/tk available', because `python.org/download/mac/tcltk` explains that macOS will only link python.exe compiled for 8.5 with 8.5. Tcl/tk 8.6 apparently has several bug fixes especially for maxOS and Python 3.7.0 will be compiled to use (and require) some 8.6.x. I do not believe that is true yet for the currently available 3.7.0a2. – Terry Jan Reedy Nov 28 '17 at 19:03
-
Thank you, again. I got what you said. Currently, there's no workaround for the bug, I think. – albert Nov 29 '17 at 05:43
1 Answers
0
See if you could use __doc__
attribute.
>>> def func():
""" Return 인사합니다 """
pass
>>> func.__doc__
' Return 인사합니다 '
Edit: I tried help(func)
on Windows 10:
>>> help(func)
Help on function func in module __main__:
func()
Return \uc778\uc0ac\ud569\ub2c8\ub2e4
I could print it right with the escape character u
prefixed to it:
>>> print(u'\uc778\uc0ac\ud569\ub2c8\ub2e4')
인사합니다
But I got the docstring
as is on Linux:
>>> help(func)
Help on function func in module __main__:
func()
Return 인사합니다

srikavineehari
- 2,502
- 1
- 11
- 21
-
1I got the right string display for __doc__. I had the problem displaying docstring by calling help() on MacOS IDLE. I got the unicode string like \uxxxx instead of Asian characters. – albert Nov 27 '17 at 08:24