You can do what you want using globals()
or locals()
.
>>> g = globals()
>>> for i in range(1, 5):
... g['depth_{0}'.format(i)] = []
...
>>> depth_1
[]
>>> depth_2
[]
>>> depth_3
[]
>>> depth_4
[]
>>> depth_5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'depth_5' is not defined
Why don't you use list of list?
>>> depths = [[] for i in range(4)]
>>> depths
[[], [], [], []]