Issue 1696390: Strange performance with unicode and lists (original) (raw)
I found some strange error (?) when using list of unicodes. Here is a small sample:
Alex in Russian
l = [u'\u0410\u043b\u0435\u043a\u0441']
print method 1
for s in l: print s.encode("utf-8")
print method 2
print [s.encode("utf-8") for s in l]
Output is:
ÐлекÑ
['\xd0\x90\xd0\xbb\xd0\xb5\xd0\xba\xd1\x81']
I suppose than output of both methods should be equal. Or maybe I'm wrong?
Python versions: 2.4.4, 2.5 (both version) OS: Ubuntu 6.10, Debian Etch
No, the output is correct. The str() of a list does a repr() of its contents, to avoid confusion e.g. in this situation:
l = ["a, b, c", "d, e, f"]
If list.str did str on its items, it would look like this:
print l [a, b, c, d, e, f]