Re: bug with itertools.groupby?

2009-10-07 Thread Paul McGuire
On Oct 6, 6:06 pm, Kitlbast wrote: > > grouped acc:  61 > grouped acc:  64 > grouped acc:  61 > > am I doing something wrong? sort first, then groupby. -- http://mail.python.org/mailman/listinfo/python-list

Re: bug with itertools.groupby?

2009-10-06 Thread Dave Angel
Kitlbast wrote: On Oct 7, 3:04 am, Raymond Hettinger wrote: On Oct 6, 4:06 pm, Kitlbast wrote: Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile'

Re: bug with itertools.groupby?

2009-10-06 Thread Kitlbast
On Oct 7, 3:04 am, Raymond Hettinger wrote: > On Oct 6, 4:06 pm, Kitlbast wrote: > > > > > > > Hi there, > > > the code below on Python 2.5.2: > > > from itertools import groupby > > > info_list = [ > >     {'profile': 'http://somesite.com/profile1', 'account': 61L}, > >     {'profile': 'http://s

Re: bug with itertools.groupby?

2009-10-06 Thread Raymond Hettinger
On Oct 6, 4:06 pm, Kitlbast wrote: > Hi there, > > the code below on Python 2.5.2: > > from itertools import groupby > > info_list = [ >     {'profile': 'http://somesite.com/profile1', 'account': 61L}, >     {'profile': 'http://somesite.com/profile2', 'account': 64L}, >     {'profile': 'http://som

Re: bug with itertools.groupby?

2009-10-06 Thread Kitlbast
Thanks guys! Miss sorting when reading docs.. ( However, I just create simple "groupby": def groupby(_list, key_func): res = {} for i in _list: k = key_func(i) if k not in res: res[k] = [i] else: res[k].append(i) return res and it work

Re: bug with itertools.groupby?

2009-10-06 Thread Rhodri James
On Wed, 07 Oct 2009 00:06:43 +0100, Kitlbast wrote: Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = [ {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile': 'http://somesite.com/profile2', 'account': 64L}, {'profile': 'http:

Re: bug with itertools.groupby?

2009-10-06 Thread Diez B. Roggisch
Kitlbast schrieb: Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = [ {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile': 'http://somesite.com/profile2', 'account': 64L}, {'profile': 'http://somesite.com/profile3', 'account': 6

bug with itertools.groupby?

2009-10-06 Thread Kitlbast
Hi there, the code below on Python 2.5.2: from itertools import groupby info_list = [ {'profile': 'http://somesite.com/profile1', 'account': 61L}, {'profile': 'http://somesite.com/profile2', 'account': 64L}, {'profile': 'http://somesite.com/profile3', 'account': 61L}, ] grouped_by_a