Message179552
I'd like to have this feature too. However the code should use
d if d is not None else {}
instead of
d or {}
For example I might want to use a subclass of dict (lowerdict) that converts all keys to lowercase. When I use an empty lowerdict in new_child(), new_child() would silently use a normal dict instead:
class lowerdict(dict):
def __getitem__(self, key):
return dict.__getitem__(
self,
key.lower() if isinstance(key, str) else key
)
import collections
cm = collections.ChainMap(lowerdict(), lowerdict())
cm2 = cm.new_child(lowerdict())
print(type(cm2.maps[0]))
This would print <class 'dict'>. |
|
Date |
User |
Action |
Args |
2013-01-10 14:36:20 | doerwalter | set | recipients:
+ doerwalter, rhettinger, vinay.sajip, r.david.murray |
2013-01-10 14:36:20 | doerwalter | set | messageid: <1357828580.69.0.115357446947.issue16613@psf.upfronthosting.co.za> |
2013-01-10 14:36:20 | doerwalter | link | issue16613 messages |
2013-01-10 14:36:19 | doerwalter | create | |
|