A short question about non-ascii characters in list

Dan Bishop danb_83 at yahoo.com
Mon Sep 17 01:23:07 EDT 2007


On Sep 17, 12:08 am, js <ebgs... at gmail.com> wrote:
> >>> print u"äöü"
> äöü
> >>> print [u"äöü"]
>
> [u'\xe4\xf6\xfc']
>
> Python seems to treat non-ASCII chars in a list differently from the
> one in the outside of a list.
> I think this behavior is so inconvenient and actually makes debugging
> work harder.
>
> Is this an intentional? Is there any doc discussing about this?

It's intentional.  __str__ of a list uses the __repr__ of its
elements.  This helps reduce confusion (e.g., between ['a', 'b, c']
and ['a, b', 'c']).




More information about the Python-list mailing list