Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
Unicode lists and join (python 2.2.3)
 

Index | Next | Previous | View Flat


nkarkhan at gmail

May 25, 2008, 12:42 PM


Views: 46
Permalink
Unicode lists and join (python 2.2.3)

Hello,
I have a list of strings, some of the strings might be unicode. I am
trying to a .join operation on the list and the .join raises a unicode
exception. I am looking for ways to get around this.
I would like to get a unicode string out of the list with all string
elements seperated by '\n'

#!/usr/bin/env python
import sys
import string

try:
x = [u"\xeeabc2:xyz", u"abc3:123"]
u = "\xe7abc"
x.append("%s:%s" % ("xfasfs", u))
x.append(u"Hello:afddfdsfa")

y = u'\n'.join(x)
print("Unicode Call worked!")
except Exception, err:
print("Exception raised %s" % err)



on a related note
Why does this work with no exceptions

x=[]
u = "\xe7abc"
x.append("%s:%s" % ("xfasfs", u))

and this doesnt
x=[]
u = "\xe7abc"
x.append("%s:%s" % (u"xfasfs", u))


Thanks,
Nitin.


--
http://mail.python.org/mailman/listinfo/python-list

Subject User Time
Unicode lists and join (python 2.2.3) nkarkhan at gmail May 25, 2008, 12:42 PM
    Re: Unicode lists and join (python 2.2.3) martin at v May 25, 2008, 1:06 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.