8000 gh-134939: Add a Multiple Interpreters Howto Doc by ericsnowcurrently · Pull Request #136143 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-134939: Add a Multiple Interpreters Howto Doc #136143

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clarify about prepare_main().
  • Loading branch information
ericsnowcurrently committed Jul 1, 2025
commit 0c3105b47963c54ab895c56052d07455897c1a5b
15 changes: 8 additions & 7 deletions Doc/howto/multiple-interpreters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -814,17 +814,18 @@ passing data between interpreters::

.. _interp-script-args:

Initializing Values for a Script
--------------------------------
Initializing Globals for a Script
---------------------------------

When you call a function in Python, sometimes that function requires
arguments and sometimes it doesn't. In the same way, sometimes a
script you want to run in another interpreter requires some values.
Providing such values to the interpreter, for the script to use,
When you call a function in Python, sometimes that function depends on
arguments, globals, and non-locals, and sometimes it doesn't. In the
same way, sometimes a script you want to run in another interpreter
depends on some global variables. Setting them ahead of time on the
interpreter's :mod:`!__main__` module, where the script will run,
is the simplest kind of communication between interpreters.

There's a method that supports this: :meth:`Interpreter.prepare_main`.
It binds values to names in the interpreter's ``__main__`` module,
It binds values to names in the interpreter's :mod:`!__main__` module,
which makes them available to any scripts that run in the interpreter
after that::

Expand Down
0