Thanks Marc, that was very helpful.
Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, manstey wrote:
>
> > I often have code like this:
> >
> > data='asdfbasdf'
> > find = (('a','f')('s','g'),('x','y'))
> > for i in find:
> >if i[0] in data:
> >data = data.replace(i[0],i[1])
>
[EMAIL PROTECTED] wrote:
> manstey:
> > is there a faster way of implementing this? Also, does the if clause
> > increase the speed?
>
> I doubt the if increases the speed. The following is a bit improved
> version:
>
> # Original data:
> data = 'asdfbasdf'
> find = (('a', 'f'), ('s', 'g'), ('x', '
In <[EMAIL PROTECTED]>, manstey wrote:
> I often have code like this:
>
> data='asdfbasdf'
> find = (('a','f')('s','g'),('x','y'))
> for i in find:
>if i[0] in data:
>data = data.replace(i[0],i[1])
>
> is there a faster way of implementing this? Also, does the if clause
> increase th
manstey schreef:
> Roel Schroeven wrote:
>> manstey schreef:
>>> I often have code like this:
>>>
>>> data='asdfbasdf'
>>> find = (('a','f')('s','g'),('x','y'))
>>> for i in find:
>>>if i[0] in data:
>>>data = data.replace(i[0],i[1])
>>>
>>> is there a faster way of implementing this? A
manstey:
> is there a faster way of implementing this? Also, does the if clause
> increase the speed?
I doubt the if increases the speed. The following is a bit improved
version:
# Original data:
data = 'asdfbasdf'
find = (('a', 'f'), ('s', 'g'), ('x', 'y'))
# The code:
data2 = data
for pat,rep
But what about substitutions like:
'ab' > 'cd', 'ced' > 'de', etc
what is the fastest way then?
Roel Schroeven wrote:
> manstey schreef:
> > Hi,
> >
> > I often have code like this:
> >
> > data='asdfbasdf'
> > find = (('a','f')('s','g'),('x','y'))
> > for i in find:
> >if i[0] in data:
> >
On 06.07.2006 12:43, manstey wrote:
> Hi,
>
> I often have code like this:
>
> data='asdfbasdf'
> find = (('a','f')('s','g'),('x','y'))
> for i in find:
>if i[0] in data:
>data = data.replace(i[0],i[1])
>
> is there a faster way of implementing this? Also, does the if clause
> increa
manstey schreef:
> Hi,
>
> I often have code like this:
>
> data='asdfbasdf'
> find = (('a','f')('s','g'),('x','y'))
> for i in find:
>if i[0] in data:
>data = data.replace(i[0],i[1])
>
> is there a faster way of implementing this? Also, does the if clause
> increase the speed?
I th
Hi,
I often have code like this:
data='asdfbasdf'
find = (('a','f')('s','g'),('x','y'))
for i in find:
if i[0] in data:
data = data.replace(i[0],i[1])
is there a faster way of implementing this? Also, does the if clause
increase the speed?
Thanks,
Matthew
--
http://mail.python.org/m