Answers for "how to set class attributes with kwargs python"

1

how to set class attributes with kwargs python

# In parent Class
def __init__(self, attributes):
	for key, value in attributes.items():
    	self.__dict__[key] = value
# In child Class
def __init__(self, **kwargs):
	attributes = {k:v for k,v in kwargs.items() if v}
    super().__init__(attributes)
Posted by: Guest on May-23-2021

Code answers related to "how to set class attributes with kwargs python"

Python Answers by Framework

Browse Popular Code Answers by Language