Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow eval and exec to take keyword arguments #105879

Closed
Assignees
JelleZijlstra
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement
@rtpg

Description

@rtpg

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!

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp