I'm looking for a way to send **kwargs to a function with defined parameters , without having to modify it.
For example , I want to pass the parameters as **kwargs when calling the following init method:
class ExampleClass(object):
def __init__(self, attr1=None, attr2=None, attr3=None):
super(ExampleClass, self).__init__()
self.attr1=attr1
self.attr2=attr2
self.attr3=attr3
Can anyone think of a way doing so?
ExampleClass(**{"attr1":1, "attr2":2, "attr3":3})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.