[docs] [issue16339] Document "exec(stmt, global_dict, local_dict)" form in Python 2?

Mark Dickinson report at bugs.python.org
Sat Oct 27 19:31:07 CEST 2012

New submission from Mark Dickinson:

In Python 2, the 'exec' statement supports 'exec'-ing a (statement, globals, locals) tuple:

>>> exec("print 2", {}, {})

This doesn't seem to be documented at http://docs.python.org/reference/simple_stmts.html#the-exec-statement.

If I understand correctly, the 'exec tuple' form was originally there for backwards compatibility with ancient versions of Python;  however, it now also conveniently provides the semblance of forwards compatibility with Python 3.  It appears to be supported by current versions of Jython (though judging by issue 403345 that wasn't always the case) and PyPy.

Is this omission intentional?  Is this form of exec an official, supported part of the Python 2 language?

assignee: docs at python
components: Documentation
messages: 173947
nosy: docs at python, mark.dickinson
priority: normal
severity: normal
stage: needs patch
status: open
title: Document "exec(stmt, global_dict, local_dict)" form in Python 2?
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the docs mailing list