Several times (even several in a row) I\'ve been bitten by the defaultdict bug: forgetting that something is actually a defaultdict and treating it like a regular dictionary
That is exactly the behavior you want from a defaultdict and not a bug. If you dont't want it, dont use a defaultdict.
defaultdict
If you keep forgetting what type variables have, then name them appropriately - for example suffix your defaultdict names with "_ddict".