5.2. Tangling code

5.2. Tangling code

So far, we have just produced a document. What about programming? Here's a sample document with tangling.
  @py = python_output('mymodule.py')
  @head(1,'My Module')
  This is my very own module.
  @select(py)
  import sys
  class myclass:
    def __init__(self, name):
      self.name = name
  @head(2,'hello method')
  Just says hello.
  @select(py)
    def hello(self):
      print 'hello','self.name
  @doc()
  And now back to doco.
Here's what the code will look like:
Start python section to mymodule.py[1]
     1: #line 201 "tutorial.pak"
     2: import sys
     3: class my class:
     4:   def __init__(self, name):
     5:     self.name = name
End python section to mymodule.py[1]