You can pass a default value to get()
for keys that are not in the dictionary:
self.val2 = kwargs.get('val2',"default value")
However, if you plan on using a particular argument with a particular default value, why not use named arguments in the first place?
def __init__(self, val2="default value", **kwargs):
from : https://stackoverflow.com/questions/1098549/proper-way-to-use-kwargs-in-python
No comments:
Post a Comment