Choice of language

Cliff Crawford cjc26 at nospam.cornell.edu
Tue May 16 13:40:02 EDT 2000


* Bob Glickstein <bobg at emphatic.com> menulis:
| 
| Also, because Python's syntax is line-oriented and because whitespace
| is significant, it would be much harder to mix together code and text
| and preserve the layout of the original.  For instance, if this were a
| Latte paragraph, I could embed a call to {\function} like so and the
| output of the function would appear integrated into the paragraph,
| with the surrounding whitespace intact.  Latte uses a particular model
| to represent the lexical structure of the input document, including
| the whitespace surrounding each word and code construct, that does not
| appear workable with Python's lexical structure.

I just took a quick glance at the Latte page, and it looks like the
easiest thing to do would be to define a new command {\py expr}, which
evaluates a python expression and merges its output (if any) into the
text at that point.  You could define new python functions using this
too:

{\py def func():
        print "Nobody expects latte-drinking Pythonistas!"
}

You'd also have to modify the latte parser so that it pays attention to
indentation.  Since you're going to have to embed a python interepreter
in it anyway, I don't think this part will be too hard :)


-- 
cliff crawford    -><-    http://www.people.cornell.edu/pages/cjc26/
"One man's nirvana is another man's map."              icq 68165166



More information about the Python-list mailing list