unicode bit me

anuraguniyal at yahoo.com anuraguniyal at yahoo.com
Sun May 10 18:04:03 CEST 2009


yes but my list sometimes have list of lists

On May 10, 2:59 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> anuraguni... at yahoo.com schrieb:
>
> > ok that explains it,
> > so
> > unicode(obj) calls __unicode__ on that object and if it isn't there
> > __repr__ is used
> > __repr__ of list by default return a str even if __repr__ of element
> > is unicode
>
> > so my only solution looks like to use my own list class everywhere i
> > use list
> > class mylist(list):
> >     def __unicode__(self):
> >         return u"["+u''.join(map(unicode,self))+u"]"
>
> Or you use a custom unicode_list-function whenever you care to print out
>   a list.
>
> Diez




More information about the Python-list mailing list