Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sweave for python

I've recently started using Sweave* for creating reports of analyses run with R, and am now looking to do the same with my python scripts.

I've found references to embedding python in Sweave docs, but that seems like a bit of a hack. Has anyone worked out a better solution, or is there an equivalent for python I'm not aware of?

* Sweave is a tool that allows to embed the R code for complete data analyses in latex documents

like image 418
pufferfish Avatar asked Jan 29 '10 10:01

pufferfish


2 Answers

I have written a Python implementation of Sweave called Pweave that implements basic functionality and some options of Sweave for Python code embedded in reST or Latex document. You can get it here: http://mpastell.com/pweave and see the original blog post here: http://mpastell.com/2010/03/03/pweave-sweave-for-python/

like image 129
Matti Pastell Avatar answered Oct 04 '22 01:10

Matti Pastell


Some suggestions:

  1. I have been using Pweave for several years now, and it is very similar to Sweave. Highly recommended.
  2. The most popular tool for embedded reports in python at this stage is Jupyter notebooks, which allow you to embed markdown, and they are quite useful although I personally still like writing things in LaTeX...
  3. You can also have a look at PyLit, which is intended for literate programming with Python, but not as well maintained as some of the alternatives.
  4. Sphinx is great for documenting with python, and can output LaTex.
  5. Here's a list of tools for literate programming. Some of these work with any programming language.
like image 20
Shane Avatar answered Oct 03 '22 23:10

Shane