Created
December 8, 2019 03:17
-
-
Save KentaYamada/dbcb49404d936ffbae9a1463355b33f3 to your computer and use it in GitHub Desktop.
Mapping dictionary to object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CarMaker: | |
def __init__(self, id=None, name=''): | |
self.id = id | |
self.name = name | |
dict_car_maker = { | |
'id': 1, | |
'name': 'toyota' | |
} | |
car_maker = CarMaker(**dict_car_maker) | |
print('ID: {0}, Name: {1}'.format(car_maker.id, car_maker.name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment