<div dir="ltr">On Thu, Sep 4, 2008 at 5:21 PM, Fredrik Lundh <span dir="ltr"><<a href="mailto:fredrik@pythonware.com">fredrik@pythonware.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Robert Dailey wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I currently have a dictionary object that I'm doing the following with:<br>
<br>
if lib not in stage_map:<br>
    # ... do stuff ...<br>
<br>
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?<br>
</blockquote>
<br></div>
dictionary lookups use the exact value.  to make a case-insensitive lookup, use key.lower() instead of key when creating the dictionary, and then do<br>
<br>
    if lib.lower() not in state_map:<br>
        ...</blockquote></div><br>So you're saying to ensure that stage_map's keys are initially lower-case to begin with? Well, I can't do this either since the case of the keys is actually valuable later on. It's only for the purposes of this specific comparison operation that the case should be ignored.<br>
</div>