compile() source code from a string

Alex new_name at mit.edu
Thu Mar 1 19:33:02 EST 2001


>>> print compile.__doc__
compile(source, filename, mode) -> code object

Compile the source string (a Python module, statement or expression)
into a code object that can be executed by the exec statement or eval().
The filename will be used for run-time error messages.
The mode must be 'exec' to compile a module, 'single' to compile a
single (interactive) statement, or 'eval' to compile an expression.
>>> 

So, you want the 'exec' option.

Alex.




More information about the Python-list mailing list