Gavin Panella added the comment: It's inconsistent that defaultdict([]) should be rejected:
>>> defaultdict([]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: first argument must be callable or None but defaultdict.fromkeys([]) is okay: >>> defaultdict.fromkeys([]) defaultdict(None, {}) The constructor signature differs between defaultdict and dict, and defaultdict.fromkeys is an alternate constructor, so it seems reasonable to also change its signature. Also confusing is that I can call fromkeys on an instance of defaultdict: >>> dd = defaultdict(list) >>> dd.fromkeys([1]) defaultdict(None, {1: None}) Instinctively I expect the default_factory to be carried over, even though I realise that would be odd behaviour for Python. If defaultdict.fromkeys were to expect a mandatory default_factory argument there wouldn't be this moment of confusion. ---------- nosy: +allenap _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23372> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com