If I make a simple function in python, it has both __dict__ and func_dict as attributes, both of which begin as empty dictionaries:
>>> def foo(): ... return 42 ... >>> foo.__dict__ {} >>> foo.func_dict {}
If I add the attribute to foo , it will appear in both:
>>> foo.x = 7 >>> foo.__dict__ {'x': 7} >>> foo.func_dict {'x': 7}
What is the difference between these attributes? Is there a specific case of using one over the other?
Barry source share