Python based macro processor (URGENT)

pehr anderson pehr at pehr.net
Fri Jul 7 21:24:30 EDT 2000


Dear Fernando,

There have been previous requests for a python preprocessor but
in most cases python had enough built-in functionality to 
gracefully deal with the problem at hand. 

Perhaps you could describe your problem in detail and let
the good folks on this list with far more experience than I
guide you to a simpler more elegant solution than preprocessing.

Who knows? 
It's pretty easy to whip up a single-purpose preprocessor
in python!

text = open(filename).read()
for line in string.split(text,"\n"):   
   if len(line) > 7 and line[0:6]=="#define":
	deftxt, var, data = string.split(line, None, 3)
	text = string.replace(text, var, data)
open(filename + ".out","w").write(text)

	-pehr

"Fernando Rodríguez" wrote:
> 
> Hi!
> 
>     Is there any Python based macro processor? O:-) I'm looking for
> something like m4, but with a saner syntax... :-)
> 
> TIA
> 
> --
> 
> ---------------------------------------
> Fernando Rodríguez



More information about the Python-list mailing list