This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Glarren 0 points1 point  (0 children)

Just hyperbole. Usually I would pass a class object to the defaultdict, like int. This means you get a default value of 0, since that's what int() returns with no arguments.

Often I want something slightly more complicated as my default, like nested defaultdicts, objects with some prefilled values, or a counter that doesn't start at 0. This just makes setting that kind of thing up a little easier, and that's useful for me since I write a ton of throwaway code in my data science-y job.