empy 1.3 -- Embed Python in template text as markup

Neil Hodgson nhodgson at bigpond.net.au
Mon Aug 26 12:21:01 CEST 2002


Erik Max Francis:

> I see what you're getting at now.  It seems straightforward enough that
> I don't see much reason _not_ to implement it, but am not sure what
> general appeal it might have.

   I'm not convinced myself and am pushing the idea out mostly for
discussion and thinking about. Don't bother with an implementation just
because of me.

   One good aspect of using arbitrary Python expressions rather than my old
simple substitution pattern is that Python's join allowed natural line
continuations

LEXOBJS= \
 $(DIR_O)\LexAda.obj \
 $(DIR_O)\LexAVE.obj
#!

   rather than my old extra line ugliness

LEXOBJS= \
 $(DIR_O)\LexAda.obj \
 $(DIR_O)\LexAVE.obj \

#--

   Having full Python functionality is very useful. I have several projects
that use some form of templating. It is tempting to change them over to empy
although it would be extra effort for something that already works well
enough. I'll probably wait until a new project needs templating and then use
empy for that.

> As you point out, ! would be a bad choice since it appears legally in
> Python code.  (This discussion also made me just realize that @<... :
> ...> for try/catch like behavior with expressions was a mistake, since >
> can appear perfectly legally in expressions ... no matter, I can
> collapse it all into an uber-@( ... ) syntax.)
>
> What would you suggest? @: ... : ... :?  It's something I would expect
> only advanced users to need, so it's probably not a problem if it
> doesn't look too pretty.

   Since it is an expression, ':' is unlikely to appear as it would in
blocks of code so that looks like a good choice.

   I couldn't see any way to quote markup characters. A quoting mechanism
could lessen problems with particular markup character choices such as the
'>' you mention above or if a @() expression were to use ')'.

   Neil





More information about the Python-list mailing list