[Python-ideas] An Alternate Suite Delineation Syntax For Python? (was Re: [Python-Dev] [PATCH] Adding braces to __future__)

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Dec 12 06:21:26 CET 2011

> Mike Meyer wrote:
>> With significant whitespace, you have to keep explicit track of the
>> current nesting level in order to generate the appropriate
>> indent. With real delimiters, you can drop that.

Yes, but with an appropriate design you can arrange for that to
be done in only *one* place. There's no need for every method
that generates code to know about indentation levels.

For example, you can create a code-output-stream object that you
pass to your code-generating methods. You give it begin_block()
and end-block() methods that you call whenever you would
otherwise have written opening and closing delimiters. It
keeps track of the indentation level internally and emits the
appropriate amount of whitespace before each line.


More information about the Python-ideas mailing list