čt 28. 4. 2022 v 13:33 odesílatel Stephen Tucker <stephen_tuc...@sil.org> napsal: > > Hi PythonList Members, > > Consider the following log from a run of IDLE: > > ================== > > Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] > on win32 > Type "copyright", "credits" or "license()" for more information. > >>> print (u"\u2551") > ║ > >>> print ([u"\u2551"]) > [u'\u2551'] > >>> > > ================== > > Yes, I am still using Python 2.x - I have good reasons for doing so and > will be moving to Python 3.x in due course. > > I have the following questions arising from the log: > > 1. Why does the second print statement not produce [ ║] or ["║"] ? > > 2. Should the second print statement produce [ ║] or ["║"] ? > > 3. Given that I want to print a list of Unicode strings so that their > characters are displayed (instead of their Unicode codepoint definitions), > is there a more Pythonic way of doing it than concatenating them into a > single string and printing that? > > 4. Does Python 3.x exhibit the same behaviour as Python 2.x in this respect? > > Thanks in anticipation. > > Stephen Tucker. > -- > https://mail.python.org/mailman/listinfo/python-list
Hi, I'm not sure, whether I am not misunderstanding the 4th question or the answers to it (it is not clear to me, whether the focus is on character printing or the quotation marks...); in either case, in python3 the character glyphs are printed in these cases, instead of the codepoint number notation, cf.: ================== Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit ( AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print ([u"\u2551"]) ['║'] >>> >>> print([u"\u2551"]) ['║'] >>> print("\u2551") ║ >>> print("║") ║ >>> print(repr("\u2551")) '║' >>> print(ascii("\u2551")) '\u2551' >>> ================== (Even the redundant u prefix from your python2 sample is apparently accepted, maybe for compatibility reasons.) hth, vbr -- https://mail.python.org/mailman/listinfo/python-list