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 rhettinger
Recipients SilentGhost, allenap, justanr, rhettinger, serhiy.storchaka, veky
Date 2016-09-20.03:39:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474342766.35.0.325244188932.issue23372@psf.upfronthosting.co.za>
In-reply-to
Content
[Serhiy]
I'm inclined to reject this proposition. It serves very special use case.

[Silent Ghost]
Correct me if I'm wrong but this seem as a very unlikely use case

[Alec Nikolas Reiter]
Implicitly assigning the factory is a pretty good compromise, like I said fromkeys accepting the factory would be a nice convenience rather than correcting a major oversight.

-----

After thinking about the above, I'm disinclined to make the API modification.

The current way to do it is straight-forward and reads nicely:

    >>> d = defaultdict.fromkeys('abcdefg', somedefault)
    >>> d.default_factory = somefunc

Combining those into a single step is less readable and may incorrectly imply some sort of interaction between the factory function and initial population of keys with a constant default value.   Likewise, the possibility of implicitly guessing and assigning the factory function is contraindicated by the zen-of-python in at least two places.

Given the paucity of use cases, the potential for API confusion, and the ready availability of reasonable alternatives, I'm closing the feature request.  Thank for the suggestion though, it certainly seemed like something that deserved a little more thought.
History
Date User Action Args
2016-09-20 03:39:26rhettingersetrecipients: + rhettinger, allenap, SilentGhost, serhiy.storchaka, veky, justanr
2016-09-20 03:39:26rhettingersetmessageid: <1474342766.35.0.325244188932.issue23372@psf.upfronthosting.co.za>
2016-09-20 03:39:26rhettingerlinkissue23372 messages
2016-09-20 03:39:25rhettingercreate