Extracting arbitrary amounts of data from a dictionary.
jmoy.matecon at gmail.com
Thu Jul 5 23:21:36 CEST 2007
On Jul 6, 12:31 am, robinsieb... at gmail.com wrote:
> I had nothing better to do, so I thought I would make a database that
> contained the songs played on the internet radio station I listen to
> (hardradio.com) so I could see how many differents songs/artists they
> So I end up with a the number of times any given song by a given
> artist is played in a day. Want I want to do is to be able to print
> out a report for X number of weeks and I am trying to determine the
> best way to interate through the 'week' key of the dictionary.
> For example, this is week 27, the dictonary has 6 'week' keys and I
> want the data from the last 3 weeks. Is this the best way to iterate
> through the dictionary?
> for date in dates[year][week].keys()[-3]:
> Or is there a better way with all the new features that have been
> added to Python?
Here is an implementation using as many 'new' features of Python as I
could think of.
More information about the Python-list