[Python-ideas] in str.replace(old, new), allow 'old' to accept a tuple
INADA Naoki
songofacandy at gmail.com
Thu Apr 12 15:17:30 CEST 2012
Oh, I didn't know that. Thank you.
But what about unescape? str.translate accepts only one character key.
On Thu, Apr 12, 2012 at 10:10 PM, Sven Marnach <sven at marnach.net> wrote:
> INADA Naoki schrieb am Thu, 12. Apr 2012, um 20:32:45 +0900:
>> >>> "<>&".replace( ('<', '<'), ('>', '>'), ('&', '&') )
>> '<>&'
>
> In current Python, it's
>
> >>> t = str.maketrans({"<": "<", ">": ">", "&": "&"})
> >>> "<>&".translate(t)
> '<>&'
>
> Looks good enough for me.
>
> Cheers,
> Sven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
--
INADA Naoki <songofacandy at gmail.com>
More information about the Python-ideas
mailing list