Question about collections.defaultdict

Steven W. Orr steveo at syslang.net
Mon Mar 26 09:33:28 EDT 2012


I created a new class called CaseInsensitiveDict (by stealing from code I 
found on the web, thank you very much). The new class inherits from dict. It 
makes it so that if the key has a 'lower' method, it will always access the 
key using lower

I'd like to change the place where I previously declared a dict

self.lookup = defaultdict(list)

so that the new code will allow this new dict to be used instead. But then I 
realized I may have painted myself into a small corner:

Is there a way to use defaultdict so that I can override what *kind* of dict 
it will use?

I would like the value to still be a list be default, but it seems like I 
can't tell defaultdict to use *my* new dict.

Do I give up on defaultdict?

BTW, 2.6 if it matters.

TIA :-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the Python-list mailing list