I'm sorry to bump up an old thread, but whatever happened to this? I was just using 'groupby' in Python for a common data migration pattern I've developed...

# Build a dictionary of parent -> child relationships
# from a datbase query, for quick and dirty data migration.
# This runs in linear time.
{
    y[0], tuple(y[1])
    for y in
    groupby(
        some_query_func(
            "SELECT parent_id, ... "
            # ...
            "ORDER BY parent_id "
        ),
        lambda x: x["parent_id"]
    )
}

... and I was thinking "it would be nice to have this in D, too!"

Reply via email to