When teaching #Python debugging recently, I've been using this:

>>> vars(some_obj)

Instead of this:

>>> some_obj.__dict__

Why?

1) I prefer high-level operations over direct dunder access when possible (e.g. str(x) over x.__str__())
2) It's two fewer characters 😆

Follow

@treyhunner I wish that the built-in vars worked with classes that don't have a `__dict__` (slotted classes). The best you can do is manually iterate through slots and use getattr with all of them but that's a hassle.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.