idiom for initial list of lists

Alex cut_me_out at hotmail.com
Fri Sep 8 12:59:56 EDT 2000


> > S=[]
> > for i in range(n): S[i].append([])
> 
>    That's the only and one correct way.

Here are some other ways that I like:

l = [[] for i in range(10)]
import copy; l = map(copy.copy, 10*[[]])

Alex.

-- 
Talk softly and carry a big carrot.




More information about the Python-list mailing list