In article <[EMAIL PROTECTED]>, Michele Petrazzo <[EMAIL PROTECTED]> wrote: >Hi, >a lot of times I need to replace more than one char into a string, so I >have to do something like > >value = "test" >chars = "e" >for c in chars: > value = value.replace(c, "") > >A solution could be that "replace" accept a tuple/list of chars, like >that was add into the new 2.5 for startswith. > >I don't know, but can be this feature included into a future python release?
Let's say you want to make every vowel uppercase: import string trans_table = string.maketrans('aeiou', 'AEIOU') "I don't know, but can be this feature included into".translate(trans_table) prints: "I dOn't knOw, bUt cAn bE thIs fEAtUrE InclUdEd IntO" That more than addresses your requirements, as it can do multiple character substitutions multiple times in one call. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list