Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.

ANN: empy 1.0 -- Embed Python in template text as markup

Skip to first unread message

Erik Max Francis

Jul 23, 2002, 4:35:47 PM7/23/02

empy (formerly Munch) is a system for embedding Python expressions
and statements in template text (or any other unexecuted content);
it takes source files, processes them, and produces output. These
are done via expansions, which are snippets of Python code delimited
by character sequences involving a special prefix (by default the at
sign, '@'), and are substituted in the output with the return
value (for expressions) or with any in-Python printing to stdout
that takes place (for both expressions and statements). If the
value of an evaluated expression is None, nothing is expanded
(that is, it acts like the interactive Python interpreter).
Textual data not explicitly delimited in this way is sent
unaffected to the output file, allowing Python to be used in
effect as a markup language. Explicit expansion, or inclusion of
other files to be expanded, is possible. Also supported are
m4-style diversions, where output can be systematically deferred
and recalled.

Expressions are embedded in text with the '@(...)' notation; as a
shortcut, simple variables and expressions can be abbreviated as
'@variable', '@object.attribute', '@array' [index],
'@function(arguments)', or variations. Full-fledged statements
are embedded with '@{...}'. A '@' followed by a whitespace
character (including a newline) expands to nothing, allowing line
continuations. Comments are indicated with '@#' and consume the
rest of the line, including the trailing newline. A '@@' sequence
expands to a single literal at sign.

Getting the software

The software is available in a tarball here:

The official URL for this Web site is

Erik Max Francis / /
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ See the son in your bad day / Smell the flowers in the valley
\__/ Chante Moore Aliens vs. Predator 2 /
A personal guide to Aliens vs. Predator 2.

0 new messages