Re: creating and appending to a dictionary of a list of lists

2007-08-15 Thread pyscottishguy
On Aug 15, 8:08 am, Ant <[EMAIL PROTECTED]> wrote: > On Aug 15, 3:30 am, [EMAIL PROTECTED] wrote: > > > Hey, > > > I started with this: > > > factByClass = {} > > ... > > def update(key, *args): > > x = factByClass.setdefault(key, [[], [], [], [] ]) > > for i, v in enumerate(args): > >

Re: creating and appending to a dictionary of a list of lists

2007-08-15 Thread Ant
On Aug 15, 3:30 am, [EMAIL PROTECTED] wrote: > Hey, > > I started with this: > > factByClass = {} > ... > def update(key, *args): > x = factByClass.setdefault(key, [[], [], [], [] ]) > for i, v in enumerate(args): > x[i].append(v) > > Is there a better way? Well, the following is p

creating and appending to a dictionary of a list of lists

2007-08-14 Thread pyscottishguy
Hey, I started with this: factByClass = {} def update(key, x0, x1, x2, x3): x = factByClass.setdefault(key, [ [], [], [], [] ]) x[0].append(x0) x[1].append(x1) x[2].append(x2) x[3].append(x3) update('one', 1, 2, 3, 4) update('one', 5, 6, 7, 8) update('two', 9, 10, 11, 12) p