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

Erik Max Francis max at
Sat Aug 17 08:23:17 CEST 2002


    empy 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', '@function(arguments)',
    '@sequence[index]', and combinations.  Full-fledged statements
    are embedded with '@{...}'.  A '@' followed by a whitespace
    character (including a newline) expands to nothing, allowing
    string concatenations and line continuations.  Comments are
    indicated with '@#' and consume the rest of the line, up to and
    including the trailing newline.  '@%' indicate optional
    "significators," which are special forms of variable assignment
    intended to specify per-file identification information in a
    format which is easy to parse externally.  Finally, a '@@'
    sequence expands to a single literal at sign.

Getting the software

    The current version of empy is 1.2.

    The latest version of the software is available in a tarball here:

    The official URL for this Web site is


    empy should work with any version of Python from 1.5.x onward.


    This code is released under the GPL.


Release history [since 1.1]

    - 1.2; 2002 Aug 16.  Treat bangpaths as comments; 'empy.quote' for
      the opposite process of 'empy.expand'; significators ('@%'
      sequences); '-I' option; much improved documentation.

    - 1.1.5; 2002 Aug 15.  Add a separate invoke function that can be
      called multiple times with arguments to simulate multiple runs.

    - 1.1.4; 2002 Aug 12.  Handle strings thrown as exceptions
      properly; use getopt to process command line arguments; cleanup
      file buffering with AbstractFile; very slight documentation and
      code cleanup.

    - 1.1.3; 2002 Aug 9.  Support for changing the prefix from within
      the 'empy' pseudo-module.

    - 1.1.2; 2002 Aug 5.  Renamed buffering option to '-B', added '-F'
      option for interpreting Python files from the command line,
      fixed improper handling of exceptions from command line options
      ('-E', '-F').

    - 1.1.1; 2002 Aug 4.  Typo bugfixes; documentation clarification.


 Erik Max Francis / max at /
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ There is nothing so subject to the inconstancy of fortune as war.
\__/ Miguel de Cervantes
    Church /
 A lambda calculus explorer in Python.

More information about the Python-list mailing list