What's The Best Way To Do Literate Programming In Python On Windows?
Solution 1:
I have written Pweave http://mpastell.com/pweave, that is aimed for dynamic report generation and uses noweb syntax. It is a pure python script so it also runs on Windows. It doesn't fix your indent problem, but maybe you can modify it for that, the code is really quite simple.
Solution 2:
The de-facto standard in the community is IPython notebooks.
Excellent example in which Peter Norvig demonstrates algorithms to solve the Travelling Salesman Problem: http://nbviewer.ipython.org/url/norvig.com/ipython/TSPv3.ipynb
More examples listed at https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks
Solution 3:
I did this:
http://sourceforge.net/projects/pywebtool/
You can get any number of web/weave products that will help you construct a document and code in one swoop.
You can -- pretty easily -- write your own. It's not rocket science to yank the Python code blocks out of RST source and assemble it. Indeed, I suggest you write your own Docutils directives to assemble the Python code from an RST source document.
You run the RST through docutils rst2html (or Sphinx) to produce your final HTML report.
You run your own utility on the same RST source to extract the Python code blocks and produce the final modules.
Solution 4:
You could use org-mode and babel-tangle.
That works quite well, since you can give :noweb-ref to source blocks.
Here’s a minimal example: Activate org-babel-tangle, then put this into the file noweb-test.org
:
#+begin_src python :exports none :noweb-ref c
abc = "abc"
#+end_src
#+begin_src python :noweb yes :tangle noweb-test.py
def x():
<<c>>
return abc
print(x())
#+end_src
You can also use properties of headlines for giving the noweb-ref. It can then even automatically concatenate several source blocks into one noweb reference.
Add :results output
to the #+begin_src
line of the second block to see the print results under that block when you hit C-c C-c
in the block.
Solution 5:
You might find noweb 3 easier to build on Windows. It was designed to be more portable than standard noweb.
Post a Comment for "What's The Best Way To Do Literate Programming In Python On Windows?"