list organization question

MRAB google at mrabarnett.plus.com
Fri Dec 12 00:26:07 CET 2008


Robocop wrote:
> I have a list of objects, each object having two relevant attributes:
> date and id.  I'd like not only organize by id, but also by date.
> I.e. i would like to parse my list into smaller lists such that each
> new mini-list has a unique date, but consists of only objects with a
> specific id.  Are there any handy imports i could use to accomplish
> something like this?  I'm relatively new to python and as such don't
> know all of the preloaded functions at my disposal.  Thanks for any
> help in advance, the community here is always ridiculously helpful.
> 
Perhaps you could iterate through the list, building a dict of lists, 
where the key of the dict is the date.



More information about the Python-list mailing list