A short question about non-ascii characters in list

js ebgssth at gmail.com
Mon Sep 17 09:25:22 CEST 2007


Thank you for your quick reply.

> 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']).
That's make sence, but it's also true that
sometimes we want to see the contents of a list in pretty format.
So for now I need to write and use crappy mylist like this.

class mylist(list):
    def __str__(self):
        return '[' + ', '.join(self) + ']'

l = mylist([u"äöü", u"äöü", u"äöü"])
print unicode(l)


very ugly, but just works.



More information about the Python-list mailing list