list organization question

John Machin sjmachin at
Fri Dec 12 00:43:41 CET 2008

On Dec 12, 10:17 am, Robocop <btha... at> wrote:
> I'm currently trying something along the lines of a, but
> as i'm never sure how many mini-lists i'll end up with, i'm not sure
> how exactly to begin.  Maybe something like a C vector, i.e. a list of
> pointers to other lists?  Or more specifically, compare dates in my
> list, push that into some empty dates[], then do something along the
> lines of for looping over dates to create subset lists, and nesting
> some more compares within these lists to further sort the data by id.
> Sound crazy or plausible?

Crazy, yes. Plausible that you might attempt it, yes.

Learn about dictionaries. They're built in; you don't need to import

E.g. [OTTOMH; untested]

id_map = {} # maps (unique) id to the object with that id
date_map = {} # maps date to a list of ids whose objects have that
for o in olist:
    if in id_map:
        raise Exception("duplicate id: %r" %
    id_map[] = o
    if not in date_map:
        date_map[] = []

More information about the Python-list mailing list