Re: Summing a 2D list

2008-06-14 Thread Karsten Heymann
Maric Michaud <[EMAIL PROTECTED]> writes: > Le Friday 13 June 2008 17:55:44 Karsten Heymann, vous avez écrit : >> Maric Michaud <[EMAIL PROTECTED]> writes: >> > So, writing C in python, which has dictionnary as builtin type, >> > should be considered "

Re: Summing a 2D list

2008-06-13 Thread Karsten Heymann
Hi Maric, Maric Michaud <[EMAIL PROTECTED]> writes: > So, writing C in python, which has dictionnary as builtin type, > should be considered "more elegant" ? IMO that's a bit harsh. > You are comparing apples with lemons, there is no such a difference > between list index access and dictionnary

Re: Summing a 2D list

2008-06-13 Thread Karsten Heymann
Paddy <[EMAIL PROTECTED]> writes: > How does your solution fare against the defaultdict solution of: > > d = collections.defaultdict(int) > for u,s in zip(users,score): d[u] += s list: 0.931s dict + "in": 1.495s defaultdict : 1.991s dict + "if": ~2s dict + "try": ~4s I've posted the (ve

Re: Summing a 2D list

2008-06-13 Thread Karsten Heymann
Hi Björn, "BJörn Lindqvist" <[EMAIL PROTECTED]> writes: > On Fri, Jun 13, 2008 at 2:12 PM, Karsten Heymann > <[EMAIL PROTECTED]> wrote: >> summed_up={} >> for user,vote in pairs: >> if summed_up.has_key(user): >>summed_up[user]+=vote >&

Re: Summing a 2D list

2008-06-13 Thread Karsten Heymann
Hi Mark, Mark <[EMAIL PROTECTED]> writes: > I have a scenario where I have a list like this: > > UserScore > 1 0 > 1 1 > 1 5 > 2 3 > 2 1 > 3 2 > 4 3 > 4 3 > 4

Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Karsten Heymann
Hi Jeff, Jeff Nyman <[EMAIL PROTECTED]> writes: > I did try this: > > for count in range(0, len(DC_List)): > DC_List.insert(count, '') On additional note: You can be quite sure you'll never have to iterate over the length of a list (or tuple) in python. Just iterate over the list itself: for

Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Karsten Heymann
Jeff Nyman <[EMAIL PROTECTED]> writes: > from glob import glob > DC_List = glob('vcdcflx006\\Flex\\Sites\\*\\') > DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland', > LosAngeles'] > The problem is that I need to pass this list to a list control in a > wxWidgets application. In or