Le Wed, 11 Sep 2013 12:38:13 +0300, Serhiy Storchaka <storchaka at gmail.com> a écrit : > 2. Subclassing. > > class CaseInsensitiveDict(TransformDict): > def transform(self, key): > return key.casefold() > d = CaseInsensitiveDict(Foo=5) I thought about this first, and then I remembered that python-dev isn't generally very keen on subclassing-based APIs :-) > 3. Type generator. > > d = TransformDict(str.casefold)(Foo=5) > [...] > > Third method allows you to customize other aspects of dict behavior > (combine OrderedDict, defaultdict,..). Well, no, it's not that easy. Especially since OrderedDict and defaultdict weren't written with combination in mind. Regards Antoine.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4