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


Groups > comp.lang.python > #22187

Question about collections.defaultdict

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <steveo@syslang.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.159
X-Spam-Level *
X-Spam-Evidence '*H*': 0.70; '*S*': 0.01; 'method,': 0.09; 'override': 0.09; 'question?': 0.09; 'stealing': 0.09; ':-)': 0.15; 'declared': 0.16; 'fruit': 0.16; 'to:name:python list': 0.16; 'zero.': 0.16; 'previously': 0.20; 'instead.': 0.22; 'subject:Question': 0.22; 'header:User-Agent:1': 0.23; 'seems': 0.28; 'this.': 0.28; '(by': 0.29; 'default,': 0.29; 'code': 0.29; 'class': 0.29; "i'd": 0.29; 'none': 0.34; 'there': 0.35; 'happened': 0.35; 'things': 0.36; 'web,': 0.36; 'but': 0.36; 'does': 0.36; 'thank': 0.37; 'list': 0.37; 'called': 0.38; "can't": 0.39; 'to:addr:python-list': 0.39; 'allow': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'god': 0.67; 'lower': 0.67; 'listen': 0.67; 'license': 0.69; 'realized': 0.72; "driver's": 0.84; 'flies': 0.84; 'holes': 0.84; 'matters.': 0.84; 'me!': 0.84; 'stranger': 0.84; 'divided': 0.91; '000': 0.93
Date Mon, 26 Mar 2012 09:33:28 -0400
From "Steven W. Orr" <steveo@syslang.net>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
MIME-Version 1.0
To python list <python-list@python.org>
Subject Question about collections.defaultdict
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1001.1332768827.3037.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332768827 news.xs4all.nl 6972 [2001:888:2000:d::a6]:53343
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22187

Show key headers only | 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