Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
ericsnowcurrently wants to merge23 commits intopython:mainChoose a base branch fromericsnowcurrently:multiple-interpreters-howto
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes from1 commit
Commits
Show all changes
23 commits Select commitHold shift + click to select a range
96e1e78 Add the multiple interpreters howto doc.
ericsnowcurrentlye5e980e Drop extraneous changes.
ericsnowcurrently2fcaedd Finish howto doc, minus recipes.
ericsnowcurrentlyaea8278 Add a TODO list.
ericsnowcurrently4bb1e2f Drop the execcomponents ref.
ericsnowcurrentlyd1ab402 Fix a ref.
ericsnowcurrently1c2d40f Drop the examples section for now.
ericsnowcurrentlyade2ce3 Fix typos.
ericsnowcurrently40f50e7 Add a misc section to the tutorial.
ericsnowcurrently0c3105b Clarify about prepare_main().
ericsnowcurrently6028349 Fix a pseudo-ref.
ericsnowcurrentlyd7a7cf0 Fix the examples.
ericsnowcurrentlyfb13944 Tweak one example.
ericsnowcurrently72e46fb Add a ref.
ericsnowcurrently675246d Clarify about Interpreter.exec().
ericsnowcurrently22e3ee0 Clarify about calling different kinds of function.
ericsnowcurrentlyf7661da Clarify a note.
ericsnowcurrently28f0218 Add a caveat about -c and the REPL.
ericsnowcurrently1b79755 Add a pro tip.
ericsnowcurrentlyb75c380 Add run-examples.py and fix some of the examples.
ericsnowcurrently35101a0 Do not try reformatting run-examples.py.
ericsnowcurrentlyddae34c Fix some of the examples.
ericsnowcurrently652abd3 Do not lint run-examples.py.
ericsnowcurrentlyFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Clarify about prepare_main().
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit0c3105b47963c54ab895c56052d07455897c1a5b
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
15 changes: 8 additions & 7 deletionsDoc/howto/multiple-interpreters.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -814,17 +814,18 @@ passing data between interpreters:: | ||||||||||
| .. _interp-script-args: | ||||||||||
| InitializingGlobals for a Script | ||||||||||
| --------------------------------- | ||||||||||
Comment on lines +1033 to +1034 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
| ||||||||||
| 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:mod:`!__main__` module, | ||||||||||
| which makes them available to any scripts that run in the interpreter | ||||||||||
| after that:: | ||||||||||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.