Monthly Archives: April 2010

delaying computation: lazy dictionaries in Python

Yesterday I had a problem I ended up solving another way, but my first approach required a lazy dictionary.  That is, a dictionary filled with the results of some other function, but also one that only evaluated this computation when the dictionary was first accessed. Read more »

python thirty days ago

These tiny things make Python fun and useful:

import datetime
thirty_days = datetime.timedelta(days=30)
thirty_days_ago = datetime.date.today() - thirty_days

plotting the racial makeup of Chicago’s public schools

schools

I created this image using matplotlib and the data from my CPS Racial Data Warehouse project.  Circle size represents school population.  The axes are latitude and longitude (as a reference, the loop is the empty rectangle just below the left corner of the legend).  Also I should note the Native American population was excluded from this image because of a technical issue.

Full size image here, more on this project soon (in the meantime, the code is here).