adam deprince wrote: > On 4/3/06, Ian Bicking <[EMAIL PROTECTED]> wrote: > [snip] > >>Adam gave one possible implementation. Another would be a keyed >>dictionary, e.g.,: KeyedDict(key=lambda s: s.lower()). A keyed >>dictionary would internally call that function on keys to get the "true" >>key, but things like .keys() would return the keys that were passed in. > > > I'm sorry, I should have been more clear. My "implementation," if > you can even call it that, was intended as a counter-example to > Talin's suggestion. > > Talin's concern was addressed long ago with the ability to subclass > built in types. Its easy to flavor a dict to act however you want. > My point wasn't "look how easy this is, lets add it to the core > language" but rather "look how easy the core language makes it for you > to do this yourself." > > IMHO, if you want a flavor of dict, extend it yourself. Case > insensitivity has no place in the core language.
I think a keyed dictionary is just as useful a case as defaultdict, though like defaultdict I don't think it needs to be part of dict itself. I strongly favor a greater number of collection patterns being in the standard library, including things like bags and multidicts and ordered dictionaries and all that. People are reinventing these things all the time, with varying levels of robustness, performance, and different APIs. For example, many people implement case insensitive dictionaries with key normalization, but I think the keyed form is generally better (though less obvious). -- Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
