Franck Pommereau

doc converted

......@@ -41,7 +41,7 @@ class Token (str) :
non-mutable object and this __init__ could not assign a str
content. For more information see:
http://docs.python.org/reference/datamodel.html#object.__new__
http://docs.python.org/reference/datamodel.html#object.__new__
"""
kind = token[0]
text = token[1]
......@@ -196,10 +196,8 @@ class Tokenizer (object) :
- skip: a collection of tokens that the tokenizer will
automatically skip (default to [COMMENT, NL])
- additional keywords arguments allow to define new tokens,
for instance, providing
DOLLAR='$'
defines a new token called 'DOLLAR' (its kind will be
automatically computed)
for instance, providing DOLLAR='$' defines a new token
called 'DOLLAR' (its kind will be automatically computed)
An instance of Tokenizer has the following attributes:
- self.opmap: a dict mapping operators token literals to the
......
......@@ -17,13 +17,16 @@ def interleave(inter, f, seq):
f(x)
class Unparser:
"""Methods in this class recursively traverse an AST and
output source code for the abstract syntax; original formatting
is disregarged. """
"""Methods in this class recursively traverse an AST and output
source code for the abstract syntax; original formatting is
disregarged.
"""
def __init__(self, tree, file = sys.stdout):
"""Unparser(tree, file=sys.stdout) -> None.
Print the source for tree to file."""
Print the source for tree to file.
"""
self.f = file
self._indent = 0
self.dispatch(tree)
......@@ -31,7 +34,9 @@ class Unparser:
self.f.flush()
def fill(self, text = ""):
"Indent a piece of text, according to the current indentation level"
"""Indent a piece of text, according to the current indentation
level
"""
self.f.write("\n" + " "*self._indent + text)
def write(self, text):
......
This diff is collapsed. Click to expand it.