Initializing a list to a known number of elements in Python

Joan Venge picture Joan Venge · Feb 6, 2009 · Viewed 602.4k times · Source

Right now I am using a list, and was expecting something like:

verts = list (1000)

Should I use array instead?

Answer

Steve Losh picture Steve Losh · Feb 6, 2009

The first thing that comes to mind for me is:

verts = [None]*1000

But do you really need to preinitialize it?