Re: Case-insensitive string compare?

2008-09-16 Thread Maric Michaud
Le Friday 05 September 2008 19:36:56 Fredrik Lundh, vous avez écrit : Maric Michaud wrote: I suspect you are coming to conclusions a bit quickly, without taking the pain of understanding the whole discussion. I'm pretty sure I was the first one to post an answer in this thread, and I

Re: Case-insensitive string compare?

2008-09-05 Thread Fredrik Lundh
Maric Michaud wrote: premature optimization is the root of all evil So is use by that statement by people who don't have the slightest idea about what it actually means. The full version is We should forget about small efficiencies, say about 97% of the time: premature optimization is

Re: Case-insensitive string compare?

2008-09-05 Thread Fredrik Lundh
Maric Michaud wrote: You''ll often see for loops written like this : for i in (e for e in iterable if predicate(e)) : ... luckily, I don't. most people, when faced with that problem, writes it in the obvious way: for i in iterable: if predicate(i): ... to avoid

Re: Case-insensitive string compare?

2008-09-05 Thread Maric Michaud
Le Friday 05 September 2008 08:30:44 Fredrik Lundh, vous avez écrit : Maric Michaud wrote: You''ll often see for loops written like this : for i in (e for e in iterable if predicate(e)) : ... luckily, I don't. most people, when faced with that problem, writes it in the obvious

Re: Case-insensitive string compare?

2008-09-05 Thread Maric Michaud
Le Friday 05 September 2008 08:24:29 Fredrik Lundh, vous avez écrit : Maric Michaud wrote: premature optimization is the root of all evil So is use by that statement by people who don't have the slightest idea about what it actually means. The full version is We should forget about small

Re: Case-insensitive string compare?

2008-09-05 Thread J. Clifford Dyer
On Thu, 2008-09-04 at 18:48 -0500, Robert Dailey wrote: Thanks everyone for your help. I'm not opposed to using [key.lower() for key in stage_map] at all, I was just curious to see if there were any cleaner alternatives. It looks like that is what I'll be using. I'm not familiar with how

Re: Case-insensitive string compare?

2008-09-05 Thread J. Cliff Dyer
Please keep the discussion on-list. On Fri, 2008-09-05 at 15:36 +0200, Maric Michaud wrote: Le Friday 05 September 2008 14:33:22 J. Clifford Dyer, vous avez écrit : On Thu, 2008-09-04 at 18:48 -0500, Robert Dailey wrote: Thanks everyone for your help. I'm not opposed to using [key.lower()

Re: Case-insensitive string compare?

2008-09-05 Thread Maric Michaud
Le Friday 05 September 2008 14:33:22 J. Clifford Dyer, vous avez écrit : On Thu, 2008-09-04 at 18:48 -0500, Robert Dailey wrote: Thanks everyone for your help. I'm not opposed to using [key.lower() for key in stage_map] at all, I was just curious to see if there were any cleaner

Re: Case-insensitive string compare?

2008-09-05 Thread Maric Michaud
Le Friday 05 September 2008 16:00:39 J. Cliff Dyer, vous avez écrit : Please keep the discussion on-list. Sorry for the private email, I sent it again to the list.. On Fri, 2008-09-05 at 15:36 +0200, Maric Michaud wrote: Le Friday 05 September 2008 14:33:22 J. Clifford Dyer, vous avez écrit

Re: Case-insensitive string compare?

2008-09-05 Thread Fredrik Lundh
Maric Michaud wrote: I suspect you are coming to conclusions a bit quickly, without taking the pain of understanding the whole discussion. I'm pretty sure I was the first one to post an answer in this thread, and I understand Python design and performance issues very well, thank you. (but

Re: Case-insensitive string compare?

2008-09-05 Thread Ethan Furman
Maric Michaud wrote: Le Friday 05 September 2008 14:33:22 J. Clifford Dyer, vous avez écrit : On Thu, 2008-09-04 at 18:48 -0500, Robert Dailey wrote: Thanks everyone for your help. I'm not opposed to using [key.lower() for key in stage_map] at all, I was just curious to see if there were any

Re: Case-insensitive string compare?

2008-09-05 Thread Robert Dailey
On Fri, Sep 5, 2008 at 12:36 PM, Fredrik Lundh [EMAIL PROTECTED]wrote: Maric Michaud wrote: I suspect you are coming to conclusions a bit quickly, without taking the pain of understanding the whole discussion. I'm pretty sure I was the first one to post an answer in this thread, and I

Case-insensitive string compare?

2008-09-04 Thread Robert Dailey
Hi, I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ... However, this will perform a case-sensitive comparison between lib and each key in stage_map. Is there a way to make this do a case-insensitive comparison instead? Yes, I

Re: Case-insensitive string compare?

2008-09-04 Thread Robert Dailey
On Thu, Sep 4, 2008 at 5:14 PM, Robert Dailey [EMAIL PROTECTED] wrote: Hi, I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ... However, this will perform a case-sensitive comparison between lib and each key in stage_map.

Re: Case-insensitive string compare?

2008-09-04 Thread Fredrik Lundh
Robert Dailey wrote: I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ... However, this will perform a case-sensitive comparison between lib and each key in stage_map. Is there a way to make this do a case-insensitive

Re: Case-insensitive string compare?

2008-09-04 Thread Robert Dailey
On Thu, Sep 4, 2008 at 5:21 PM, Fredrik Lundh [EMAIL PROTECTED]wrote: Robert Dailey wrote: I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ... However, this will perform a case-sensitive comparison between lib and each

Re: Case-insensitive string compare?

2008-09-04 Thread Maric Michaud
Le Friday 05 September 2008 00:14:37 Robert Dailey, vous avez écrit : Hi, I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ... However, this will perform a case-sensitive comparison between lib and each key in stage_map.

Re: Case-insensitive string compare?

2008-09-04 Thread Chris Rebert
On Thu, Sep 4, 2008 at 3:37 PM, Robert Dailey [EMAIL PROTECTED] wrote: On Thu, Sep 4, 2008 at 5:21 PM, Fredrik Lundh [EMAIL PROTECTED] wrote: Robert Dailey wrote: I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ...

Re: Case-insensitive string compare?

2008-09-04 Thread Maric Michaud
Le Friday 05 September 2008 00:47:00 Chris Rebert, vous avez écrit : On Thu, Sep 4, 2008 at 3:37 PM, Robert Dailey [EMAIL PROTECTED] wrote: On Thu, Sep 4, 2008 at 5:21 PM, Fredrik Lundh [EMAIL PROTECTED] wrote: Robert Dailey wrote: I currently have a dictionary object that I'm doing the

Re: Case-insensitive string compare?

2008-09-04 Thread Robert Dailey
On Thu, Sep 4, 2008 at 5:59 PM, Maric Michaud [EMAIL PROTECTED] wrote: Le Friday 05 September 2008 00:47:00 Chris Rebert, vous avez écrit : Then store the string in its original case in the value part of the key-value pair: stage_map[key.lower()] = (key,whatever) premature