[Python-ideas] Transportable indent level markers. >>>===<<<

Nick Coghlan ncoghlan at gmail.com
Thu Dec 15 02:21:34 CET 2011


On Thu, Dec 15, 2011 at 9:53 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> But a moot point unless we actually do want a standardized transport
> encoding for indents and dedents.

And if we *were* going to do that, it's far more sensible to use a
scheme that is at least *theoretically* open to the possibility of
eventually allowing suite expressions.

For the record, if anyone really wants to play with this, I'd start
with the tokenize module, and figure out what tweaks are needed to
create the following mappings between the source code and the token
stream:

"{:"  <-> token.OP(":"), token.NEWLINE, token.INDENT

":}"  <-> token.NEWLINE, token.DEDENT

Then you can do source-source transforms by taking the output of the
tweaked tokenizer and feeding it to the standard one and vice-versa.

That's should be all you really need to create a delimited syntax
variant. Things only get complex if you try to turn that delimited
syntax variant into multi-line lambda support.

P.S. See http://bugs.python.org/issue2134 in regard to why you can't
use token.COLON for this

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list