parser.compilest(st, filename='')
The Python byte compiler can be invoked on an ST object to produce code objects which can be used as part of a call to the built-in exec()
or eval()
functions. This function provides the interface to the compiler, passing the internal parse tree from st to the parser, using the source file name specified by the filename parameter. The default value supplied for filename indicates that the source was an ST object.
Compiling an ST object may result in exceptions related to compilation; an example would be a SyntaxError
caused by the parse tree for del f(0)
: this statement is considered legal within the formal grammar for Python but is not a legal language construct. The SyntaxError
raised for this condition is actually generated by the Python byte-compiler normally, which is why it can be raised at this point by the parser
module. Most causes of compilation failure can be diagnosed programmatically by inspection of the parse tree.
Please login to continue.