Cow header

Publish Python Scripts with Pweave

Author: Matti Pastell
Tags: Python, Pweave
Apr 19 2013

I have been working on Pweave lately and one new feature for the next release is a new input format and a HTML template that allows easy publishing of regular python scripts. The feature is similar to MATLAB’s publish and the input format for doc and code chunks has been adopted from knitr’s spin. You can use the new format instead of the old noweb format for any document, one advantage is that you can also run the code without Pweave as a normal Python script which makes debugging easier.

Have a look at couple of examples about published scipts:

FIR filter design html, pdf and code. Also explains the basics of the format.
Linear regression html, pdf and code. Linear regression using statsmodels.

Try it out

I’d appreciate any feedback before the next version is released, so drop me a mail if you have any thoughts.

Publishing scripts is easy: Get the current development version from Bitbucket repo and install it. You’ll also need python-markdown and for markdown2Mathjax to use inline math.

Publish a script to html from the command line.


And to pdf (requires pandoc and pdflatex):

pypublish -f pdf
comments powered by Disqus