Python Inline Eval
Python Inline Eval brings inline Python evaluation to VS Code. Run the current line, a selection, or an entire file and see the result directly in the editor while keeping a live Python session active between evaluations.
It is built for fast exploratory work: short values stay inline, larger output expands into a preview panel, and full execution details are written to an output channel.
It fits script-first workflows where you want notebook-style feedback without moving into a notebook.
Why Python Inline Eval
Python Inline Eval is designed for the gap between a full notebook and a plain script. It lets you probe values, verify transformations, and inspect output without breaking flow or switching to a separate REPL window.
Features
- Evaluate the current line, current selection, or complete file.
- Keep a persistent Python session alive so variables, imports, and state carry across runs.
- Show compact inline results with expanded details available on hover.
- Preserve multiple inline results instead of replacing previous ones.
- Open a preview panel automatically for structured values or longer output.
- Write value, stdout, stderr, and traceback output to a dedicated channel.
- Restart the session at any time and inspect the current interpreter and session state.
- Display the active interpreter in the status bar.
Requirements
- VS Code 1.90 or newer.
- A working Python interpreter.
- The Python extension is optional, but recommended if you want Python Inline Eval to follow the active environment selected in VS Code.
Quick Start
- Open a Python file.
- Run one of the Python Inline Eval commands from the Command Palette or editor context menu.
- Read the inline result at the end of the evaluated line.
- Hover the inline result for more detail, or open the preview panel for expanded output.
Feature Demo
Use Python Inline Eval like a lightweight inline REPL inside a normal Python file:
numbers = [1, 2, 3, 4]
sum(numbers)
Evaluate the second line and the result appears inline at the end of that line.
Then continue in the same file:
average = sum(numbers) / len(numbers)
average
Because the Python session stays alive, previously defined values remain available until you restart the session.
For larger values such as nested dictionaries, lists, or mixed stdout and return values, Python Inline Eval keeps the inline preview compact and sends the expanded details to the preview panel and output channel.
Screenshots
Before publishing to the Marketplace, add real captures for these views:
- Inline result shown at the end of an evaluated Python line.
- Preview panel open with a structured value.
- Output channel showing value, stdout, stderr, or traceback sections.
These three screenshots cover the core workflow most users need to understand at a glance.
Commands
Python Inline Eval: Evaluate Current Line
Python Inline Eval: Evaluate Selection
Python Inline Eval: Evaluate File
Python Inline Eval: Restart Session
Python Inline Eval: Session Info
Extension Settings
pythonInlineEval.interpreterPath: Use a specific interpreter path instead of the active interpreter from the Python extension.
pythonInlineEval.preview.inlineMaxLength: Set the maximum inline preview length before truncation.
pythonInlineEval.preview.itemLimit: Limit how many items appear in structured previews.
pythonInlineEval.preview.depth: Limit nested preview depth for complex values.
pythonInlineEval.previewPanel.autoOpen: Automatically open the preview panel for structured or expanded output.
pythonInlineEval.outputChannel.autoOpen: Automatically reveal the output channel after evaluation.
Interpreter Selection
Python Inline Eval resolves the interpreter in this order:
pythonInlineEval.interpreterPath, if set.
- The active interpreter reported by the Python extension.
- A fallback command from the system path (
python on Windows, python3 elsewhere).
When the active interpreter changes, Python Inline Eval refreshes the session so execution stays aligned with the environment currently in use.
Output Experience
Each evaluation can surface information in three places:
- Inline in the editor for quick feedback.
- In the preview panel for longer or structured values.
- In the output channel for full execution details, including stdout, stderr, and tracebacks.
This makes it practical to inspect simple expressions without leaving the editor while still having access to complete execution output when needed.
Known Limitations
- A selection taken from inside an indented block may not run by itself if Python would reject that code outside its original context.
- The extension uses one shared execution session, so globals and imports are shared across evaluations until the session is restarted.
Development
npm install
npm run compile
npm test
npm run package:vsix
The packaging step includes the compiled extension and Python runner while excluding tests and transient build artifacts.
License
This project is licensed under the MIT License.