New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document "exec(stmt, global_dict, local_dict)" form in Python 2? #60543
Comments
In Python 2, the 'exec' statement supports 'exec'-ing a (statement, globals, locals) tuple: >>> exec("print 2", {}, {})
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 bpo-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? |
Thread on #python-dev: http://mail.python.org/pipermail/python-dev/2012-November/122543.html If this is documented, direct tests for this form of exec should also be added. |
Here's a patch for the documentation and tests. |
Updated patch: drops mention of backwards compatibility, since that's not so useful (thanks, Ezio!). Adds note about resemblance to Python 3 code. |
Rewording the sentence about Python 3. |
New changeset fd9c9579050d by Mark Dickinson in branch '2.7': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: