Example how to programmatically create and execute an IPython notebook, in response to this question on StackOverflow. Click here to view the example on nbviewer. Click here to see the result of executing the automatically generated notebook.