How to change behavior of dict() for an instance
So I'm writing a class that extends a dictionary which right now uses a method "dictify" to transform itself into a dict. What I would like to do instead though is change it so that calling dict() on the object results in the same behavior, but I don't know which method to override. Is this not possible, or I am I missing something totally obvious? (And yes, I know the code below doesn't work but I hope it illustrates what I'm trying to do.) from collections import defaultdict class RecursiveDict(defaultdict): ''' A recursive default dict. >>> a = RecursiveDict() >>> a[1][2][3] = 4 >>> a