Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22187

Question about collections.defaultdict

Date 2012-03-26 09:33 -0400
From "Steven W. Orr" <steveo@syslang.net>
Subject Question about collections.defaultdict
Newsgroups comp.lang.python
Message-ID <mailman.1001.1332768827.3037.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Question about collections.defaultdict "Steven W. Orr" <steveo@syslang.net> - 2012-03-26 09:33 -0400

csiph-web