Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Description
Feature or enhancement
Allow forglobals
andlocals
to be passed in as keyword arguments toexec
andeval
.
Pitch
exec
andeval
both can takeglobals
andlocals
as positional arguments.
The built-in functions documentation shows the argument defaults, andevery time I have the documentation open and am writing these, I default to keyword arguments, and it fails because the arguments are positional-only.
For 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 introducingeval
/exec
now that we would explicitly disallow kwargs.
Previous discussion
I sentthis email topython-ideas
Extra Links
Here is an implementation, 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!