Creating a List of Empty Lists
Robin Becker
robin at jessikat.fsnet.co.uk
Sat Dec 6 13:29:44 EST 2003
More information about the Python-list mailing list
Sat Dec 6 13:29:44 EST 2003
- Previous message (by thread): Creating a List of Empty Lists
- Next message (by thread): Creating a List of Empty Lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <Xns9447973F01BFduncanrcpcouk at 127.0.0.1>, Duncan Booth <duncan at NOSPAMrcp.co.uk> writes ...... > >The recommended way these days is usually: > > a = [ [] for i in range(10) ] > >That still has a loop and works by appending empty lists, but at least its >just a single expression. Also you can incorporate the next stage of your >initialisation quite easily: > > a = [ [b] for b in range(10) ] > I seem to remember the fastest way to do this was map(list,n*[[]]) from a couple of earlier threads, but is that true in 2.3? -- Robin Becker
- Previous message (by thread): Creating a List of Empty Lists
- Next message (by thread): Creating a List of Empty Lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list