There are so many great tools in the collections module, it's impossible to keep them all straight. I've been reminded of defaultdict probably a dozen times over the last few years and end up forgetting about it again until I make a bunch of spaghetti .get() calls. FWIW I believe it's been around since Python 2 but I haven't checked to be sure.
View all comments
Show parent comment
7
u/[deleted] Jul 14 '21
Didn’t know that existed, I guess it arrived later in Python3?
Or I didn’t read the docs properly!