Andromeda
Note

Python Interpreter

Definition

A program that executes Python code line-by-line in a “Read-Eval-Print Loop” (REPL), providing immediate feedback without the need to save and run a script file.

Why It Matters

The interpreter is your “dialogue” with the machine. Understanding how it works (REPL vs. Script) is the difference between efficient, iterative development and frustrating trial-and-error. It enables the rapid “feedback loop” that is Python’s greatest advantage, allowing you to test, inspect, and discard ideas before they become rigid structures in a script.

Core Concepts

  • Interactive Mode (REPL): Best for testing small snippets of code and inspecting variables in real-time. Indicated by the >>> prompt.
  • Script Mode: Running a .py file from start to finish. This is the standard for automation and production.
  • Optimization Flag (-O): Running Python as python -O script.py disables all assert statements, improving performance for production environments.
  • The Windows Launcher (py.exe): A specialized small program that finds and launches the latest version of Python installed on a Windows machine.

Connected Concepts