Python dictionary from an object’s fields

Note that best practice in Python 2.7 is to use new-style classes (not needed with Python 3), i.e. Also, there’s a difference between an ‘object’ and a ‘class’. To build a dictionary from an arbitrary object, it’s sufficient to use __dict__. Usually, you’ll declare your methods at class level and your attributes at instance level, so __dict__ should be fine. For … Read more