Raymond Hettinger added the comment: [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. ---------- resolution: -> rejected status: open -> closed _______________________________________ 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