Did you know you can get at your object's data in dictionary form?
All you need to do is use the _dict_ attribute of our object.
Calling my_object.__dict__ will return a dictionary containing the attributes of that object.
But there's more!
We can also use vars() to accomplish the same thing. All we have to do is call vars and pass in our object. It will retain a dictionary of that object's attributes!
コメント