Re: string.translate with unicode

2006-08-06 Thread bearophileHUGS
[EMAIL PROTECTED]: It's not a bug, but such incompatibility problem will probably be solved with Python 3.0, when most strings will managed as unicode. The documentation says: >it returns a copy of the s where all characters have been mapped through the >given translation table which must be a

string.translate with unicode

2006-08-06 Thread [EMAIL PROTECTED]
This has always worked fine for me. >>> import string >>> id = "Peter! *fine*" >>> transtab = string.maketrans('/ ','_ ') >>> print string.translate(id, transtab, '?&!;<=>*#[]{}') Peter fine Now if I do it with a unicode string: >>> id = u"Peter! *fine*" >>> transtab = string.maketrans('/ ','_ ')