Skip to content
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

Injecting variables into locals #20

Open
Technologicat opened this issue Aug 8, 2019 · 0 comments
Open

Injecting variables into locals #20

Technologicat opened this issue Aug 8, 2019 · 0 comments
Labels
discussion Thinking it over - comments welcome! wontfix This will not be worked on
Milestone

Comments

@Technologicat
Copy link
Owner

In short: in recent Pythons, impossible, by design. This is probably a good thing.

In Python ≤ 3.6, as discussed on stupidpythonideas, there was PyFrame_LocalsToFast in the CPython C API, which could be accessed via ctypes. This no longer works in 3.7 and later (PEP 558).

The alternative of using inspect.stack() and mutating the f_locals attribute of the frame object doesn't work, either.

See also Everything in Python is mutable.

(This issue is intentionally left open to collect links to related reading.)

@Technologicat Technologicat added question Further information is requested wontfix This will not be worked on labels Aug 8, 2019
@Technologicat Technologicat added this to the far-future milestone Aug 8, 2019
@Technologicat Technologicat added discussion Thinking it over - comments welcome! and removed question Further information is requested labels Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Thinking it over - comments welcome! wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant