aa_macro syntax 
 aa_macro source 
 HTML source 
 HTML render 
Key

§ 4.66 - [pythparse] Built-In

Mnemonic aid: pythparse

See also:  [pythparse] )

This built-in allows you to generate a pretty-printed representation of Python source code to a local variable, loc_pyth. In the example, you'll see I wrapped a  <div>  with a black background around the retrieval of the loc_pyth variable, as the default pretty-printing colors were selected with a black background in mind.

There are some details to consider here; please refer to the notes below the examples on this page.

def mygen(n): names = ['Ben','Deb'] for i in range(0,n): print "hello" + names[0] and names[1]
Warning:

 [pythparse] ) must be used at the top level; you can't embed it in a style or another built-in. It can handle Python code without any changes, but again, only in the top level context.

Caution:

Although  [pythparse] ) takes raw Python, the aa_macro parser still has to wade through it to find the closing ] for the  [pythparse] ) built-in itself. So if there are unbalanced [] or {} anywhere in the Python source, that will break the parsing. An easy fix for this is to balance to a pair in the comments before (if ] or }) or after (if [ or {) the line of Python. Sorry about that, but it's inherent in how all this works.

Because of this, it may be more convenient to edit all the occurrences of [, ], { and } to  [lb] ) ,  [rb] ) ,  [ls] ) and  [rs] ) and then use  [postparse] ) instead. It's basically a tradeoff between getting a perfect code representation and having to do some manipulating of comments as described here.

One last thing: If you are displaying Python that contains aa_macro source, you should definitely use  [pythparse] ) ; this is because  [postparse] ) will actually process anything like that that it finds.

You can control what the pretty printing does in terms of styling by setting the following variables (default values are shown):

CSS style wrap for Python keywords: import, while, etc.
tx_prekey
postparse
tx_poskey
postparse

CSS style wrap for single and double quotes
tx_prequo
postparse
tx_posquo
postparse

CSS style wrap for Python code
tx_precod
postparse
tx_poscod
postparse

CSS style wrap for text inside quotes
tx_pretxt
postparse
tx_postxt
postparse

CSS style wrap for comment content
tx_precom
postparse
tx_poscom
postparse

CSS style wrap for {}, [], and ()
tx_pybrace
postparse
tx_epybrace
postparse

CSS style wrap for symbols such as ==, +, < and so on
tx_pysym
postparse
tx_epysym
postparse
Keyboard Navigation
, Previous Page . Next Page t TOC i Index
This manual was generated with wtfm
on January 10th, 2026 at 2:38 MT
wtfm uses aa_macro and SqLite
aa_macro uses Python 2.7