Need help initializing a list or tuple.

Terry Reedy tjreedy at udel.edu
Mon Mar 6 15:18:47 EST 2006


"KraftDiner" <bobrien18 at yahoo.com> wrote in message 
news:1141666188.237150.320690 at j52g2000cwj.googlegroups.com...
> Thank you that worked great!
>
> a = [[None] * 256] * 256
> for i in range(0,256):
> for j in range(0,256):
> a[i][j] = i**2
>
> Now.. Can I change this quickly into a 1 dimensional list of length
> 65536?

If 'a' were a Numeric/Numarray/NumPy array, then I believe you could 
re-dimensionalize it on the fly to be 1x65536 instead of 256x256.  See 
numeric.scipy.org for more.

tjr






More information about the Python-list mailing list