question about speed of sequential string replacement vs regex or

Roy Smith roy at panix.com
Wed Sep 28 09:29:57 EDT 2011


In article <9egld1F385U1 at mid.individual.net>,
 Neil Cerutti <neilc at norwich.edu> wrote:

> On 2011-09-28, Chris Angelico <rosuav at gmail.com> wrote:
> > On Wed, Sep 28, 2011 at 10:28 PM, Xah Lee <xahlee at gmail.com> wrote:
> >> each string needs to be changed to a unique string, not all to
> >> the same string.
> >
> > And you'll find that this is, by and large, the most normal
> > situation. Folding many strings down to one string is a lot
> > less common. So, let's have some real-world use cases and then
> > we can talk recommendations.
> 
> I'd like to know what "string replacement" is supposed to mean in
> the context of Python.

You just need to use "string" in the more generic computer-sciency 
sense, not in the python-data-type sense.

s = "I am an immutable string"
l = list(s)      # now you can pretend strings are mutable
do_stuff_to_string(l)
s = ''.join(l)



More information about the Python-list mailing list