[Python-ideas] Literate python?

Mike Meyer mwm at mired.org
Thu Mar 10 00:34:51 CET 2011

On Tue, 08 Mar 2011 21:01:25 -0500
Terry Reedy <tjreedy at udel.edu> wrote:

> On 3/8/2011 5:02 PM, Mike Meyer wrote:
> > Wild idea, swiped directly from haskell/ghc:
> >
> > How about making the python interpreter just a little bit smarter,
> It already is ;-)
> Though not exactly well known, expression statements that consist of a 
> literal (number or string) are ignored -- except for string literals in 
> docstring position (and then, they are attached as attributes, rather 
> than being in the code object.

[Examples elided]

> > If the first non-white-space character after the shebang line (if
> > present) is a backslash, then the compiler ignores lines until it sees
> > a line consisting of \begin{code} (which could be the first line),
> > then compiles lines until it sees a line consisting of \end{code},
> > after which it switches back to searching for \begin{code}.
> So this appears unnecessary. Just use quotes.

That works fine for the '> ' variant. But the point of the \...{code}
version is that the resulting source could be run through both lpython
and TeX without preprocessing. How does using quotes play with TeX?

> The main problems is that program editors are generally not smart enough 
> to do auto text wrapping within multiline strings.

Emacs MMM-mode
(http://www.xemacs.org/Documentation/packages/html/mmm.html) should
work for this - or the two variants I suggested (switching from Python
to TeX mode dynamically).

Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

More information about the Python-ideas mailing list