Suppose I have a given Object (a string \"a\", a number - let\'s say 0, or a list [\'x\',\'y\'] )
I\'d like to create list containing many copies of thi
If you want unique instances and like to golf, this is (slightly) shorter:
L = [['x', 'y'] for _ in []*10]
The crazy thing is that it's also (appreciably) faster:
>>> timeit("[['x', 'y'] for _ in [0]*1000]", number=100000)
8.252447253966238
>>> timeit("[['x', 'y'] for _ in range(1000)]", number=100000)
9.461477918957826