[Python-Dev] Idea of the Month: Preprocessor

Raymond Hettinger python@rcn.com
Mon, 18 Mar 2002 18:03:59 -0500


Enable a command line option [-p filename.py] and a related environment
variable PYTHONPREPROCESS.  The new behavior of the interpreter would then
be to submit all of its input to the preprocess program (a module written in
pure python) and then interpret the result.

The goal is to enable experimentation with proposed language features
without having to write and compile a python extention or alter the parser
in any way.  The anti-goals are to avoid use in production programs and
avoiding creating a macro system for the language as a whole.  In other
words, make experimentation easy while keeping the language itself pure and
avoid the weirdness that macro systems make possible.

This idea would make it easy to experiment with the effects of proposed
PEPs.  Experimentation is important for evaluation -- a lot of folks who
thought list comprehensions were a bad idea found that they came to like
them after some experimentation.  Right now, I'm inclined to believe that
the proposed 'for i in 3:' integer iteration idea is a bad thing; however,
direct experimentation could possibly convince me otherwise.  For the time
being, the discussion of its merits will remain abstract and ungrounded as
compared to a more meaningful and concrete discussion that would ensue from
some experience the idea.



Raymond Hettinger           <-- No longer afraid of reptiles