Sunday, February 26, 2012


I think I need to create a script that

1. Scans my gmail inbox for any mail whose subject line uses ALL CAPS and which urges me to forward it to everyone I know;
2. Searches for the message body;
3. Replies with a link to the top Snopes hit and its text, plus a preachy little sermon by me on the importance of Truth

... all automatically.

What sort of tools can I use to make such a script?

If you don't know, please forward my question on to everyone you know. It's very important. It probably involves President Obama and/or dead babies.

Wednesday, February 22, 2012

slides from Saturday class

Hi, Python students from Saturday! Hope you enjoyed the class, and thanks for your patience as we struggled with wireless issues.

Here's the updated class materials I promised - if you can, install Visual Python on your machine and try out some of the suggestions given in the comments at the bottom of and

I'm very fortunate to be able to go to PyCon this year, and I plan to come to the Dayton Dynamic Languages meeting the following Wednesday (March 14) bubbling over with stuff I learn there - I'd love to see you there! Bring whatever Python project you've been working on and we'll help push you over any bumps you've hit, or strategize on ideas for new projects.

Tuesday, February 14, 2012

Growth in PyCon sponsorship

When I teach Python, I usually include a slide or two about Python's importance and growth. At this point, that's begun to feel unnecessary - but I think I will include this illustration, because it's a neat one.

In 2004, I'd just started looking at Python. When I found out that PyCon would be just a few miles from my sister-in-law's house, I thought, "Why not?" - and I fell in love with the Python community forever. PyCon 2004 had nine sponsors.

This year, I barely squeaked my registration in before the blast doors slammed shut. Here are PyCon US 2012's sponsors.

Sunday, February 12, 2012

Free Python class in Dayton

This Saturday (Feb 18, 2012), Sinclair Community College in Dayton will host Python: Programming is Fun Again, a two-hour introduction to the language.

It's a hands-on workshop, so bring a laptop if you can.

I'm teaching, so you can expect some planets to collide. However, this time, the aim is to help you get your own feet wet in actual programming. We'll start with simple 3-D graphical scenarios, and students will decide how to tweak and evolve the programs from there.

Contact Dr. Shirley Stallworth ( to register and for detailed directions and parking information.

Afterward, you can stop by TechFest, also running at Sinclair!

Pass the word along!

February 18, 2012 1012pm
Python: Programming is Fun Again
Sinclair Community College, room 14130
444 W 3rd Street
Dayton OH 45402-1453 USA
A free, hands-on introduction to Python programming
Free Python class in Dayton

This hCalendar event brought to you by the hCalendar Creator.

Saturday, February 11, 2012

HTSQL-powered Flask

With seven lines of code, you can plug HTSQL into a web application platform like Flask. Yes, I know that you know SQLAlchemy already; the point is that then your Flask apps can support HTSQL's rich in-the-URL filtering language. (Also, it lets you skip the schema definition step for read-only apps.)

For instance, this app serves reports from HTSQL's sample "University" database. Each report can run as-is


or can accept arbitrary HTSQL filters


The advantage over plain HTSQL is that you can use full Flask power. In this case, the reports come through a template that includes functioning links in each row, so it's a drill-down report:

<td><a href="/departments?code='{{ row.department_code }}'">
{{ row.dept }}</td>

Here are the magic seven lines:

htsql = HTSQL('pgsql:uni') # customize me

def data(qry):
filters = flask.request.url.replace(flask.request.base_url, '', 1)
if filters and ('?' in qry): # this can be fooled by a filtered subquery
filters = '&%s' % filters.strip()[1:]
qry = '%s%s' % (qry, filters or '')
return htsql.produce(qry)

Now each of your report pages asks for data in the form of an HTSQL query, and the ``data`` function appends any user-supplied filters to that:

return flask.render_template('departments.html', data=data(qry))

full code for the sample app