Is it possible to initialize class variables in the dictionary. Python3.8
📁 словарь, python, пример, ии
Is it possible to somehow assign the values of the class transferred to each variable in the dictionary. For example, the class has variables: a, b, c, d -, and I convey the dictionary to the designer of the class:
Dictionary = { `` ""> 'b' : 5 , 'a' : 2 , 'c' : 45 } pre> the designer should contact the variable class by the names of the keys to the dictionary and set these values to them, while the keys can be arbitrary. DATA-HIGHLIGHTED = ""> class expain : def __ Init __ ( self, d: dict ): self.a, self.b, self.c = int # there should be a code to initiate variables transferred to dictionary if __name__ == '' __ main __ ': dictionary = {' 'b' 5 , 'a' : 2 , 'c' : 45 } ex = Example (dictionary) print (ex.b) # must deduce: "5" ".