
March 8, 2017
10:23 p.m.
Le 08/03/17 à 23:09, Steven Piantadosi a écrit :
Hi All,
I find importing defaultdict from collections to be clunky and it seems like having a default should just be an optional keyword to dict. Thus, something like,
d = dict(default=int)
would be the same as
from collections import defaultdict d = defaultdict(int)
Any thoughts?
I have never really used it, so I might say something stupid, but doesn't it prevent the use of "default" as a key in the generated dict? Would those 2 dicts be equal ? d1 = dict(default=5) d2 = {'default': 5} Brice