Topy news - and a request for Python pretty-printing

François Pinard pinard at iro.umontreal.ca
Thu Apr 11 16:44:13 EDT 2002


Hi, gang!  Just a few news and words about the Topy project.  (For those
who do not know, it is a Scheme to Python conversion tool.)

I gave Topy more hours since I last wrote to you about it.  Besides
correcting a few bugs here and there, I rewrote the scoping mechanics so
to ease later implementation of `let'/`let*'/`letrec' nuances.  The new
mechanics is oriented towards the quick switching between evaluation
contexts.  Nothing difficult theoretically, only tedious in details.

For strange reasons, I've been side-tracked into writing another Topy
front-end for Milou (a language which is 10 years old, but fully unknown
outside the company where I work, here).  Taking this opportunity, I
identified more common code and widened the back-end (yielding shortened
front-ends for both Scheme and Milou).  I also cleaning around a bit more.

Something that bothers me a bit is that the Python generated out of Scheme
input, at times, goes over 79 columns.  But for Milou, this happens very
frequently, to the point I cannot escape anymore doing something about it.
Consequently, I quickly kludged a line wrapper in the back-end which,
without being so bad, is still far from being a real pretty-printer.

Would someone happens to know if there is a pretty-printer for Python
source _lines_, where I would find some inspiration maybe?  I do not need
an indenter, there is no problem there.  The problem is to split a long
Python line into many lines which would nicely represent the original,
that is, for example, for which indentation stresses operator precedence.
Cleverly breaking long string constants is also an interesting problem!

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard






More information about the Python-list mailing list