Is there a way in Python to force to generate a new object when creating a list?
Assume I have a class Test
of which I want to store 5 objects in a list.
I use the following code to generate the list:
myList = [Test()] * 5
With this code python creates only 1 Object which is stored 5 times.
Of course I could use a for-loop to generate the list. But in my real program this would blow up the code extremly, because I have about 30 lists, which are partly nested in another List.
So Is there a fast way (maybe a one-liner) to force python to generate a new Object in each entry?