At some level it was sloppy thinking, yes; most bugs have some obvious-in-retrospect reason they were stupid. You may be right about how to think about this one.
I've seen other defaultdict bugs -- this is just the case with the highest eyeball-count-times-attention product I can point to.
If this bug was simply due to having the wrong concept of defaultdict, and if the others you saw were the same, then you can avoid the bugs forever by just having the right concept. Lots of ifs there, of course.
I've seen other defaultdict bugs -- this is just the case with the highest eyeball-count-times-attention product I can point to.