question about speed of sequential string replacement vs regex or

Chris Angelico rosuav at gmail.com
Wed Sep 28 15:32:49 CEST 2011


On Wed, Sep 28, 2011 at 11:22 PM, Neil Cerutti <neilc at norwich.edu> wrote:
> I'd like to know what "string replacement" is supposed to mean in
> the context of Python.
>

Substring replacement, such as:
>>> "Hello, world!".replace(", "," -- ")
'Hello -- world!'

The str method doesn't accept a list, though, so it won't do
simultaneous replaces. (At least, I don't think it can. Tried it only
in Python 3.2 on Windows.)

ChrisA



More information about the Python-list mailing list