[issue19210] Unicode Objects in Tuples
Martin v. Löwis added the comment: It's at https://mail.python.org/mailman/listinfo/python-list -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Stephen Tucker added the comment: Dear All (Eric Smith in particular), I see the issue has been closed - I guess that I have to use e-mail to continue this discussion. I attach a source file that demonstrates the feature, and the output from IDLE that it generated. Yours, Stephen Tucker. On Wed, Oct 9, 2013 at 6:10 PM, Eric V. Smith rep...@bugs.python.orgwrote: Eric V. Smith added the comment: Can you provide some code which demonstrates this? It's easier to address this if we have known working (or non-working) examples. Thanks. -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ -- Added file: http://bugs.python.org/file32027/UnicodeTupleTestIDLEOutput.txt Added file: http://bugs.python.org/file32028/UnicodeTupleTest.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. import UnicodeTupleTest (u'\u2021',) (u'\u2021', u'\u2021') # # Set a unicode string with a non-ASCII character mystring = u'\u2021' # # Print the string print mystring # # Print the string enclosed in parentheses print (mystring) # # Print the string as the first item in a tuple whose second item is None print (mystring,) # # Set a tuple consisting of two instances of this string mytuple = (mystring, mystring) # # Print the tuple print mytuple ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Martin v. Löwis added the comment: Stephen: do you agree that your example actually doesn't demonstrate the issue you originally reported? Your first to print statements don't actually print a tuple, whereas the latter two do, and the string gets always escaped in the tuple, and never when printed directly. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Eric V. Smith added the comment: As Martin points out, your first example is printing a string, not a tuple. The parens here are not building a tuple, they are just used for grouping in the expression, and are not doing anything in this example. So my explanation still holds: everything is working as designed. The output of the first two print statements uses str(astring), the second two use str(atuple). repr of a tuple is effectively: ( + , .join(repr(item) for item in tuple) + ) So when printing your tuples, Python is using the repr of each string in the tuple. Since this is not a bug or feature request, it's probably best to continue the discussion on python-list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Stephen Tucker added the comment: Martin: Yes, I agree this does not demonstrate the issue I reported - so far as print is concerned. The other issue in my original report was that the same behaviour is exhibited when tuples are read from a utf-8 - encoded file where a tuple which has a unicode string in it with a non-ASCII character is displayed with its non-ASCII characters as escapes. Eric: I am in a quandary. I am not convinced that the appearance of such strings (under either circumstance) should be governed by whether they are in tuples or not. It still seems remarkably like a bug to me. However, I am happy to continue this discussion on Python-list, if you consider it better to do that. Please, can you tell me, how do I do that? On Thu, Oct 10, 2013 at 12:29 PM, Eric V. Smith rep...@bugs.python.orgwrote: Eric V. Smith added the comment: As Martin points out, your first example is printing a string, not a tuple. The parens here are not building a tuple, they are just used for grouping in the expression, and are not doing anything in this example. So my explanation still holds: everything is working as designed. The output of the first two print statements uses str(astring), the second two use str(atuple). repr of a tuple is effectively: ( + , .join(repr(item) for item in tuple) + ) So when printing your tuples, Python is using the repr of each string in the tuple. Since this is not a bug or feature request, it's probably best to continue the discussion on python-list. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
R. David Murray added the comment: python-list is a mailing list, so you would subscribe and post your questions and examples there. There are very good reasons for the existing behavior, and python-list would be a good place for you to learn about them (by asking questions). The file case is the same: you are using print to create the output, and it is print's rules that are being used to generate that output, before it ever gets written to the file. (And by the way, you are free to post to a closed issue. Having it closed just means it doesn't show up on our list of issues we need to fix :) -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
New submission from Stephen Tucker: If a tuple consists of a single unicode object with non-ASCII characters in it, the printing of the tuple causes the non-ASCII characters to appear correctly as characters. If the tuple contains such a unicode object and anything else (even if it contains nothing else but two or more such unicode objects), the printing of the tuple causes all non-ASCII characters in the objects to appear as their \u escapes instead of as their characters. The same thing happens when writing such tuples to a file that has been opened using codecs.open (filename, 'w', 'utf-8'). -- components: Windows messages: 199308 nosy: Stephen_Tucker priority: normal severity: normal status: open title: Unicode Objects in Tuples type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Eric V. Smith added the comment: Can you provide some code which demonstrates this? It's easier to address this if we have known working (or non-working) examples. Thanks. -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Peter Otten added the comment: Be aware that for a 1-tuple the trailing comma is mandatory: print (uäöü) # this is a string despite the suggestive parens äöü print (uäöü,) # this is a tuple (u'\xe4\xf6\xfc',) -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Eric V. Smith added the comment: This isn't strictly related to printing a tuple. It's the difference between str() and repr(): print (uäöü) # uses str äöü print repr(uäöü) u'\xe4\xf6\xfc' When the tuple is printed, it uses the repr of its constituent parts. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19210] Unicode Objects in Tuples
Antoine Pitrou added the comment: Indeed, this is a feature, even though it may seem an odd one. -- nosy: +pitrou resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19210 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com