Learning Question

Why is the file not the running program?

In the previous chapter, hello.py contained:

print("hello")

It is tempting to say “the program is hello.py.” That sentence is often useful in casual speech, but it hides several different layers.

hello.py is a source file. It stores text that Python can read as source code.

print("hello") is code. It is a source-level instruction written in the Python language.

python hello.py is a command. It asks the shell and operating system to start the Python interpreter and pass the file path to it.

The Python interpreter is the runtime program that reads the source file and executes Python behavior.

The Python process is the operating-system-managed running instance created for that command.

The output hello is observed behavior produced during that run.

None of these layers can replace all the others.

The Same Word Can Point to Different Layers

The word “program” is overloaded.

For hello.py, someone might use “program” to mean:

  • the text file stored on disk
  • the Python source code inside the file
  • the intended behavior of printing hello
  • the command being run
  • the Python interpreter process while it is running the file
  • the observed output in the terminal

Those meanings are connected, but they answer different questions.

If the question is “where is the code stored?”, the answer is the file.

If the question is “what reads the code?”, the answer is the Python interpreter.

If the question is “what is currently running?”, the answer is a process.

If the question is “what happened?”, the answer is the behavior: the terminal received hello and the process exited.

Why the Difference Matters

Different failures happen at different layers.

If hello.py is missing, the interpreter cannot read the file.

If the file contains invalid Python syntax, the interpreter starts but fails before normal execution.

If the python command cannot be found, the operating system does not start the intended interpreter process.

If print("hello") is replaced with code that waits for input, the process may be running even though no output appears yet.

If output is redirected, the program may run correctly but nothing appears in the terminal.

Calling all of these “the program does not work” is too vague. The useful question is which layer failed.

A Practical Layer Map

For the hello.py example, keep these layers separate:

LayerConcrete exampleWhat to inspect
source filehello.pyfile path, contents, encoding, permissions
source codeprint("hello")Python syntax and meaning
commandpython hello.pyshell input, arguments, working directory
interpreterpythoninstalled version, executable path, runtime behavior
processrunning Python instancePID, environment, open files, exit status
behaviorhello printedoutput, errors, side effects, timing

The table is not a universal taxonomy. It is a way to stop one broad word from hiding the layer that matters.

The Durable Distinction

Software is not one thing during execution reasoning.

It can be represented as files, expressed as code, invoked by commands, consumed by tools or runtimes, contained in processes, and observed as behavior.

When the word “software”, “code”, or “program” feels unclear, replace it with a more concrete noun:

source file
source code
command
artifact
runtime
process
behavior

That replacement usually makes the next question inspectable.