This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author allenap
Recipients SilentGhost, allenap, justanr, rhettinger, serhiy.storchaka
Date 2016-09-19.15:48:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474300085.74.0.799078848053.issue23372@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-09-19 15:48:05allenapsetrecipients: + allenap, rhettinger, SilentGhost, serhiy.storchaka, justanr
2016-09-19 15:48:05allenapsetmessageid: <1474300085.74.0.799078848053.issue23372@psf.upfronthosting.co.za>
2016-09-19 15:48:05allenaplinkissue23372 messages
2016-09-19 15:48:05allenapcreate