empy 1.3 -- Embed Python in template text as markup
nhodgson at bigpond.net.au
Mon Aug 26 01:00:09 CEST 2002
Erik Max Francis:
> One could certainly perform this kind of thing in empy, but I'm not sure
> of how much use it would be. I'm not quite seeing how to integrate such
> functionality into a tool unless it was specifically designed for it.
> (empy is the arbitrary embedding of Python code in template text, not
> for this particular type of macro operation in particular.)
First design some syntax like @!expr!...! which is replaced by
@!expr!result_of_expr! by empy. Then my example becomes
# @!"\nLEXOBJS= \\\n" + "\\ \n".join(["\t$(DIR_O)\\" + y for y in f]) +
Upon first expansion with f = ["LexAda", "LexAVE", "LexCPP"] this becomes
# @!"\nLEXOBJS= \\\n" + " \\\n".join(["\t$(DIR_O)\\" + y for y in f]) +
Further expansions yield the same result with the same f or equivalent
results with updated f.
The syntax given above is too likely to run into problems as a simple '!'
is too likely to occur in the expression or expansion, so possibly some more
'@' based tokens could be used like @!expr@~...@|
More information about the Python-list