Title: Allow eval and exec to take keyword arguments · Issue #105879 · python/cpython · GitHub
Open Graph Title: Allow eval and exec to take keyword arguments · Issue #105879 · python/cpython
X Title: Allow eval and exec to take keyword arguments · Issue #105879 · python/cpython
Description: Feature or enhancement Allow for globals and locals to be passed in as keyword arguments to exec and eval. Pitch exec and eval both can take globals and locals as positional arguments. The built-in functions documentation shows the argum...
Open Graph Description: Feature or enhancement Allow for globals and locals to be passed in as keyword arguments to exec and eval. Pitch exec and eval both can take globals and locals as positional arguments. The built-in...
X Description: Feature or enhancement Allow for globals and locals to be passed in as keyword arguments to exec and eval. Pitch exec and eval both can take globals and locals as positional arguments. The built-in...
Opengraph URL: https://github.com/python/cpython/issues/105879
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow eval and exec to take keyword arguments","articleBody":"# Feature or enhancement\r\n\r\nAllow for `globals` and `locals` to be passed in as keyword arguments to `exec` and `eval`.\r\n\r\n# Pitch\r\n\r\n`exec` and `eval` both can take `globals` and `locals` as positional arguments. \r\nThe built-in functions documentation shows the argument defaults, and _every time_ I have the documentation open and am writing these, I default to keyword arguments, and it fails because the arguments are positional-only.\r\n\r\nFor functions like this that might only be present in a handful of places, kwargs give a good way to document what parameters each argument is referring to. I don't think that in a universe in which we were introducing `eval`/`exec` now that we would explicitly disallow kwargs.\r\n\r\n# Previous discussion\r\n\r\nI sent [this email](https://mail.python.org/archives/list/python-ideas@python.org/thread/AD37KVC4CP4HQD4D7VUJTCWSP4LKEZYB/) to `python-ideas`\r\n\r\n# Extra Links\r\n\r\n[Here is an implementation](https://github.com/rtpg/cpython/commit/c4368ef213a64297954fbca4f5308d69409d6a4b), which just consists in changing the argument clinic config and rerunning. I set up some very basic kwarg tests mostly to test the case of \"locals provided but globals not provided\", but fortunately the existing implementations already handled this cleanly!\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105885\n* gh-121831\n* gh-121852\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/rtpg","@type":"Person","name":"rtpg"},"datePublished":"2023-06-17T02:43:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/105879/cpython/issues/105879"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:282486f0-dfae-a77d-c4ae-8cf521081611 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC2E:B7E00:331031:4137A0:696B3FD7 |
| html-safe-nonce | 76986cbae2417e09a59bbe9e56a565da225651c5f9ac958a4d6378ac8c148d2c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzJFOkI3RTAwOjMzMTAzMTo0MTM3QTA6Njk2QjNGRDciLCJ2aXNpdG9yX2lkIjoiNjE4MDk3ODA3ODQzMjA1MTE1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cda465a99cfb62309c3a361559ac89d0dbb4b9ef177071b8b3e29fdbc3743c51 |
| hovercard-subject-tag | issue:1761596185 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/105879/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fdc2ec56c52559feb05e2fa9816d0b8d24725d5362a376d4528052271b1c7d63/python/cpython/issues/105879 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fdc2ec56c52559feb05e2fa9816d0b8d24725d5362a376d4528052271b1c7d63/python/cpython/issues/105879 |
| og:image:alt | Feature or enhancement Allow for globals and locals to be passed in as keyword arguments to exec and eval. Pitch exec and eval both can take globals and locals as positional arguments. The built-in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rtpg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width