-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
Currently, the Python extension only supports “Run Selection/Line in Native Python REPL”.
However, there is no built-in command to run the entire file in the Native Python REPL environment, similar to how “Run Python File” works with the standard terminal.
Why this is needed
When using the Native Python REPL, it’s common to want to execute a full script rather than sending code line by line. This is particularly useful for debugging, exploratory analysis, or working with interactive environments that maintain state across executions.
Although the functionality can be partially emulated using the ryuta46.multi-command extension — by copying the entire file content and sending it to the REPL — this workaround has a critical limitation:
It cannot correctly set the Python working directory to the file’s location.
As a result, relative imports and file I/O operations may fail or behave inconsistently.
Proposed Solution
Add a new command, for example:
Python: Run File in Native Python REPL
Expected behavior
- Executes the current file in the active Native Python REPL session.
- Automatically sets the working directory (
cwd) to the directory of the executed file. - Optionally restarts the REPL before execution (similar to “Run File” behavior).
Example Use Case
I often use the Native Python REPL for fast interactive debugging. Having “Run File in Native Python REPL” would allow me to execute scripts directly while preserving the REPL context and correct working directory — something not currently achievable.
Environment
- VS Code version: 1.105.1
- Python extension version: 2025.16.0
- OS: Windows 11