caseless dictionary howto ?

Evan Klitzke evan at yelp.com
Tue Jun 19 16:34:30 EDT 2007


On 6/19/07, Stef Mientki <S.Mientki-nospam at mailbox.kun.nl> wrote:
> hello,
>
> 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.
> So I'm using a dictionary to store names and attributes of objects.
> As as I need to search on the caseless name (so I've choosen lowercase),
> My dictionairy looks like this:
>
>      self.procs [ "serial_hw_read"  ] = ( "Serial_HW_Read", "F", "++", T)
>
> Is this really a good solution,
> or are there better ways ?

Since you want an almost dictionary, you should create a new class
that inherits from dict and overloads the methods that you want to
change.

-- 
Evan Klitzke <evan at yelp.com>



More information about the Python-list mailing list