<html><body bgcolor="#FFFFFF"><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">On 9 mars 2011, at 03:01, Terry Reedy <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:</span></div><div></div><blockquote type="cite"><div><span>On 3/8/2011 5:02 PM, Mike Meyer wrote:</span><br><blockquote type="cite"><span>Wild idea, swiped directly from haskell/ghc:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>How about making the python interpreter just a little bit smarter,</span><br></blockquote><span></span><br><span>It already is ;-)</span><br><span>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.</span><br><span></span><br><span>def f():</span><br><span>    'doc' # to .__doc__</span><br><span>    1 # ignored</span><br><span>    (1,2,3) # will not be ignored, even though constand and unused</span><br><span>    # comments are ignored</span><br><span>    'same as comment'</span><br><span>    '''</span><br><span>    multiline</span><br><span>    comment</span><br><span>    '''</span><br><span></span><br><span>from dis import dis</span><br><span>dis(f)</span><br><span>>>></span><br><span>  4           0 LOAD_CONST               5 ((1, 2, 3))</span><br><span>              3 POP_TOP</span><br><span></span><br><span> 10           4 LOAD_CONST               4 (None)</span><br><span>              7 RETURN_VALUE</span><br><span></span><br><blockquote type="cite"><span>If the first non-white-space character after the shebang line (if</span><br></blockquote><blockquote type="cite"><span>present) is a backslash, then the compiler ignores lines until it sees</span><br></blockquote><blockquote type="cite"><span>a line consisting of \begin{code} (which could be the first line),</span><br></blockquote><blockquote type="cite"><span>then compiles lines until it sees a line consisting of \end{code},</span><br></blockquote><blockquote type="cite"><span>after which it switches back to searching for \begin{code}.</span><br></blockquote><span></span><br><span>So this appears unnecessary. Just use quotes.</span><br><span></span><br><span>The main problems is that program editors are generally not smart enough to do auto text wrapping within multiline strings.</span><br><span></span><br><span>-- </span><br><span>Terry Jan Reedy</span><br><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#0023A3"><br></font></font></div></blockquote>That's a far cry from lhs though (to say nothing of lit prog). Abusing doctests would be much closer to literate haskell (just about identical if you find a terse way to ignore outputs), if still a long way from knuth's literate programming. </body></html>