A short question about non-ascii characters in list

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Mon Sep 17 10:01:23 EDT 2007


js wrote:
> That's make sence, but it's also true that
> sometimes we want to see the contents of a list in pretty format.

That may be true, but most of the time not (at least not me) --
lists are no pretty printing instrument, but a container.

> 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.

What's wrong with

print ",".join(mylist)

? Also, the your solution isn't really "ugly" in my opinion.

Regards,


Björn

-- 
BOFH excuse #55:

Plumber mistook routing panel for decorative wall fixture




More information about the Python-list mailing list