Suppose I have a class like this:
class A:
def __init__(self):
self.a = "a"
self.b = "b"
How would I get a dictionary like this ?
{"a": "a", "b": "b"}
I read this question and answers, but the dictionary in these answers always contains some "dunder" attributes as well, which I never defined in A.__init__
. Will I have to use one of the solutions in the linked question and filter out the dunder attributes, or is there a smarter way ?