I recently had an epiphany, which may seem painfully obvious to most programmers, but it took me a little while longer to realize.
Under Python there is a module called doctest, which allows you to script an interactive session and look at the results. A sample would be:
>>> print 2 …