A PYM file is a macro preprocessor file based on the Python programming language. It was developed by VRVis Research and store macro shortcuts. When the PYM file is interpreted by the Python interpreter’s preprocessing stage, these shortcuts are expanded as replacements for their full text. In addition, a third, optional operation that can be performed by a macro preprocessor is file inclusion. PYM files can be opened in text editors such Notepad, Notepad++, Apple TextEdit, and VI on Linux.
PYM File Format
PYM files are saved as plain text files to disc. A PYM file can also include other files using the #include directive.
PYM statements are included between “"#begin python and “#end python” markers as shown below.
we decided to use a line based special sequence to introduce PYM macros:
#python code for defining "macros" goes here
PYM Macro Expansion
The PYM macro expansion is represented by two sequences i.e. <[ and ]>. These are special html tags and can appear anywhere in a line. A little PYM example is as follow.
TITLE = "My Web page"
def EXP(e): return str(e)
<p>The value of 2 raised to the 4th power is <[EXP(2**4)]>.</p>
The output of running this through PYM is as follow:
<title>My Web Page</title>
<h4>My Web Page</h4>
<p>The value of 2 raised to the 4th power is 16.</p>