[Tutor] converting unicode
Kent Johnson
kent37 at tds.net
Wed Dec 1 04:12:27 CET 2004
If you want a tuple as a result:
Python 2.4 way using a generator comprehension:
tuple(str(s) for s in stringtuple)
Python 2.3 uses list comprehension:
tuple([str(s) for s in stringtuple])
Old-timer's way using map :-)
tuple(map(str, stringtuple))
Kent
If a list is OK use either of the last two without the tuple() part...
Rene Bourgoin wrote:
> Wandering how i could convert an entire tuple of unicode strings to python strings using str(u'string')
>
> stringtuple = ()
> stringtuple = (u'string1',u'string2',u'string3')
>
> str(u stringtuple) # syntax problem here!!!
>
>
> thanks
>
>
> _______________________________________________
> No banners. No pop-ups. No kidding.
> Make My Way your home on the Web - http://www.myway.com
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list