Re: Can I rely on...

2009-03-20 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Do not assume. Either check or use another solution. My 2 cents... Take the following code: pattern = "aPattern" compile

Re: Can I rely on...

2009-03-20 Thread R. David Murray
alex23 wrote: > On Mar 20, 1:42 am, "Emanuele D'Arrigo" wrote: > > I just had a bit of a shiver for something I'm doing often in my code > > but that might be based on a wrong assumption on my part. Take the > > following code: > > > > pattern = "aPattern" > > > > compiledPatterns = [ ] > > compi

Re: Can I rely on...

2009-03-19 Thread alex23
On Mar 20, 1:42 am, "Emanuele D'Arrigo" wrote: > I just had a bit of a shiver for something I'm doing often in my code > but that might be based on a wrong assumption on my part. Take the > following code: > > pattern = "aPattern" > > compiledPatterns = [ ] > compiledPatterns.append(re.compile(pat

Re: Can I rely on...

2009-03-19 Thread R. David Murray
"Emanuele D'Arrigo" wrote: > Thank you everybody for the informative replies. > > I'll have to comb my code for all the instances of "item in sequence" > statement because I suspect some of them are as unsafe as my first > example. Oh well. One more lesson learned. You may have far fewer unsafe

Re: Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Thank you everybody for the informative replies. I'll have to comb my code for all the instances of "item in sequence" statement because I suspect some of them are as unsafe as my first example. Oh well. One more lesson learned. Thank you again. Manu -- http://mail.python.org/mailman/listinfo/py

Re: Can I rely on...

2009-03-19 Thread Terry Reedy
Emanuele D'Arrigo wrote: Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] compiledPatterns.append(re.compile(pattern)) if(re.compil

Re: Can I rely on...

2009-03-19 Thread Albert Hopkins
On Thu, 2009-03-19 at 08:42 -0700, Emanuele D'Arrigo wrote: > Hi everybody, > > I just had a bit of a shiver for something I'm doing often in my code > but that might be based on a wrong assumption on my part. Take the > following code: > > pattern = "aPattern" > > compiledPatterns = [ ] > compi

Re: Can I rely on...

2009-03-19 Thread MRAB
Emanuele D'Arrigo wrote: [snip] If the answer is no, am I right to state the in the case portrayed above the only way to be safe is to use the following code instead? for item in compiledPatterns: if(item.pattern == pattern): print("The compiled pattern is stored.") break Co

Re: Can I rely on...

2009-03-19 Thread MRAB
Emanuele D'Arrigo wrote: Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] compiledPatterns.append(re.compile(pattern)) if(re.compil