Running Python

  1. You can execute the Python file as a script using the command line.
  2. You can import the code from one Python file into another file or into the interactive interpreter.

Terminology

  • File: Typically, a Python file is any file that contains code. Most Python files have the extension .py
  • Script: A Python script is a file that you intend to execute from the command line to accomplish a task.
  • Module: A Python module is a file that you intend to import from within another module or a script, or from the interactive interpreter. You can read more about modules in Python Modules and Packages – An Introduction.