R. Alan Monroe wrote:
I'm wondering whether text.replace has to shove oodles of text to the
right in memory when you replace a shorter word with a longer word.
Someone else on the list may know.
Alan
Since a string is immutable, replace() has to copy the string. So it
doesn't need to
> Hi folks,
> I'm trying to do something like this:
evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'}
def make_evil(text)
> ... for a in evildict:
> ... text=text.replace(a, evildict[a])
> ... return text
>
> This works fine, but it so
On Tue, Dec 15, 2009 at 12:19 PM, Luhmann wrote:
> Hi folks,
>
> I'm trying to do something like this:
>
> >>> evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'}
>
> >>> def make_evil(text)
> ...for a in evildict:
> ... text=text.replace(a, evildict[a])
> ...
Luhmann wrote:
Hi folks,
I'm trying to do something like this:
evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'}
def make_evil(text)
...for a in evildict:
... text=text.replace(a, evildict[a])
... return text
This works fine, but it soon
Hi folks,
I'm trying to do something like this:
>>> evildict= {'good' : 'bad' , 'love' : 'hate' , 'God': 'Satan'}
>>> def make_evil(text)
... for a in evildict:
... text=text.replace(a, evildict[a])
... return text
This works fine, but it soon gets too slow