reifying indent and dedent into braces

greg greg at
Wed Oct 14 02:13:10 CEST 2009

Rustom Mody wrote:

> Context: I am trying to generate some python code and its
> indentation=structure is giving me a headache!

When I generate Python code (or anything else with an
indented structure) I usually define myself a class with
a method for writing out a line, and a pair of methods
for increasing and decreasing the indentation level.
It keeps track of the current indentation level and
automatically prepends the appropriate amount of
whitespace to each line written out.


More information about the Python-list mailing list