Curious to see alternate approach on a search/replace via regex

Serhiy Storchaka storchaka at gmail.com
Thu Feb 7 11:56:19 EST 2013


On 07.02.13 11:49, Peter Otten wrote:
> ILLEGAL = "-:./?&="
> try:
>      TRANS = string.maketrans(ILLEGAL, "_" * len(ILLEGAL))
> except AttributeError:
>      # python 3
>      TRANS = dict.fromkeys(map(ord, ILLEGAL), "_")

str.maketrans()





More information about the Python-list mailing list