Gabriel Genellina wrote:
> En Tue, 19 Jun 2007 19:40:10 -0300, Steven Bethard 
> <[EMAIL PROTECTED]> escribió:
> 
>> Stef Mientki wrote:
>>> Evan Klitzke wrote:
>>>> On 6/19/07, Stef Mientki <[EMAIL PROTECTED]> wrote:
>>>>>
>>>>> I need to search a piece of text and make all words that are equal
>>>>> (except their case) also equal in their case, based on the first
>>>>> occurrence.
> 
>> ...     def __setitem__(self, key, value):
>> ...         self._dict[key.lower()] = value
>> ...         if key not in self._original_keys:
>> ...             self._original_keys[key.lower()] = key
>> ...
>>
>> Note that because I store the first form encountered for every key, I
>> can always use the lower-case version to retrieve the "original string".
> 
> As written, it stores the last used spelling; a small change is required 
> to get the intended behavior:
> 
>> ...     def __setitem__(self, key, value):
>> ...         self._dict[key.lower()] = value
>> ...         if key.lower() not in self._original_keys:
>> ...             self._original_keys[key.lower()] = key

Good catch.  Thanks!

Steve
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to