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

Jim Jewett jimjjewett at gmail.com
Thu Dec 15 16:33:08 CET 2011


On Thu, Dec 15, 2011 at 12:25 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> (And I freely admit that my suggestion is also quite ugly. However,
> the status quo, with everyone inventing assorted templating languages
> for use with Python that are largely independent of Python itself
> already sucks)

Guido actually endorsed ugly if it is just used for transport.  That
said, for embedding in a template, I would prefer to avoid ugly.  But
why does it have to be all punctuation?


:indent 4             if is_frobbable(user, request):
:indent 5                 frob(request)
:indent 4             else:
:indent 5                  spit_error("Can't frob here, mate!")

The grammar would be that at the start of a (line, string, whatever
record marker the embedding environment has),

    the literal ":indent"
      followed by whitespace
    followed by a decimal number <count>
      followed by whitespace
    followed by a line of python code

would be equivalent to that same line of python code indented <count>
times.  Ideally, the actual leading whitespace would also demonstrate
proper indenting, but it wouldn't *need* to, so the code would be
robust against transmission.

-jJ



More information about the Python-ideas mailing list