string.translate with unicode
peterbe at gmail.com
peterbe at gmail.com
Sun Aug 6 09:05:18 EDT 2006
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('/ ','_ ')
>>> print string.translate(id, transtab, '?&!;<=>*#[]{}')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/string.py", line 493, in translate
return s.translate(table, deletions)
TypeError: translate() takes exactly one argument (2 given)
That doesn't seem fair. Is this a know bug perhaps? I tried googling
for it.
More information about the Python-list
mailing list