[Python-ideas] Allow non-callable default_factory for defaultdict

Brandon Mintern bmintern at gmail.com
Tue Jun 3 03:21:54 CEST 2008

On Mon, Jun 2, 2008 at 8:27 PM, Bruce Leban <bruce at leapyear.org> wrote:
> I don't see an extra lambda as that complicated. What is more complicated is
> that when I see the code:
> d = defaultdict(foo)
> I (the reader of the code) can't tell whether foo is the default value or
> the default function. So I better always write (lambda: foo) unless foo is a
> constant. Doesn't to have enough benefit to change.
> --- Bruce

Ahh.... that makes a lot of sense. I hadn't considered it from that angle.

Thanks for the good explanation,

More information about the Python-ideas mailing list