[ python-Bugs-1696390 ] Strange performance with unicode and lists

SourceForge.net noreply at sourceforge.net
Sun Apr 8 14:34:42 CEST 2007


Bugs item #1696390, was opened at 2007-04-08 11:44
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1696390&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.5
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Vsevolod (sv75)
Assigned to: M.-A. Lemburg (lemburg)
Summary: Strange performance with unicode and lists

Initial Comment:
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

----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2007-04-08 12:34

Message:
Logged In: YES 
user_id=849994
Originator: NO

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]

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1696390&group_id=5470


More information about the Python-bugs-list mailing list