Name

The exec Statement

Synopsis

exec codestring [in globaldict [, localdict]]

Compiles and runs code strings. codestring is any Python statement as a string; run in namespace containing the exec, or the global/local namespace dictionaries if specified (localdict defaults to globaldict). codestring can also be a compiled code object. Also see compile, eval, and execfile in Section 1.12.

Get Python Pocket Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.