Intertwines documentation and source code which emphasizes the need for code to not only be understood by the compiler, but also by future engineers trying to reason about your code.
Introduced by Donald Knuth in his book Literate Programming written in 1984 and implemented in the CWEB tool.
Literate programming with org-mode
Here’s an example of weaving the execution of code into this document which exports both the code block and output:
import random
print random.randrange(0, 100)
54
To tangle this code such that it exports to a source code file we can add the following heading to the source block tangle: hello_world :exports none
which will export the code block to a file hello_world.py
.
Read more about literate programming in org-mode using org-babel