Use `__dict__` or `vars()`?

Generally, you should consider dunder/magic methods to be the implementation and invoking functions/methods as the API, so it would be preferable to use vars() over __dict__, in the same way that you would do len(a_list) and not a_list.__len__(), or a_dict["key"] rather than a_dict.__getitem__('key')

Leave a Comment