With Python dicts, you can do the following:
thing = {} # or dict()
thing['this'] = "is"
thing["is"] = "sparta"
method(**thing)
which the method receives as
method(this="is", is="sparta")
I have a class very similar to a dict, but with a bunch of extra helper methods. I have defined __iter__
with it so that I can do "attr" in thing
. My question is, what "magic method" do I have to define (if there is one) to be able to use **
?
By the way, I would prefer not to subclass from dict
.
The way I am making it behave like a dict
is by manipulating the internal __dict__
.