My first stumbling block with Python

Greg Ewing see_reply_address at something.invalid
Thu Aug 22 23:14:24 EDT 2002


Mr. Neutron wrote:

> The answer is
> 	MyArray = [ [0]*512 for i in range(512) ]
> 
> I found this to be really peculiar and hard to understand.


It might help to see it re-written without
a list comprehension:

   MyArray = []
   for i in range(512):
     MyArray.append([0]*512)

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list