NickName:Ugnius Malūkas Ask DateTime:2018-09-19T15:31:38 How to return new Object every time by calling same dict value in Python? I am trying to set class definition for dictionary element that every time by getting dict element new object should appear. Example: types = {} types[first_type] = FirstType() types[second_type] = SecondType() And by setting types[first_type] I have to get new FirstType(): some_var = new types[first_type] # this is illegal statement. How can I achieve this in Python? Copyright Notice:Content Author:「Ugnius Malūkas」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.Link to original article:https://stackoverflow.com/questions/52400483/how-to-return-new-object-every-time-by-calling-same-dict-value-in-python Answers iBug 2018-09-19T07:33:35 Try making them into \"object generators\" themselves.\n\ntypes = {}\ntypes[first_type] = FirstType\ntypes[second_type] = SecondType\n\n\nThen you can get a new object each time by calling that that point.\n\nsome_var = types[first_type]()\n",