bug with itertools.groupby?

Kitlbast vlad.shevchenko at gmail.com
Wed Oct 7 01:06:43 CEST 2009

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_account = groupby(info_list, lambda x: x['account'])
for acc, iter_info_items in grouped_by_account:
    print 'grouped acc: ', acc

gives output:

grouped acc:  61
grouped acc:  64
grouped acc:  61

am I doing something wrong?

More information about the Python-list mailing list