Working with Python Scripts

Leave the interpreter and start writing real .py files, including how to take input and print output.

Articles

1

Writing and Running a Python Script

A Python script is a file holding Python code, and it usually carries the .py extension.

2

Input and Output Systems in Python 3

A few functions, print() and input() among them, are the standard tools most I/O work in Python is built on.

3

Python Modules: the Import That Printed the Report

You pull one function out into its own file, import it, and the whole report runs again and eats your input. A module is a file, import runs it top to bottom, and one line decides which of the two jobs it is doing.

4

Python venv: the Install That Went Into the Wrong Python

pip install printed Successfully installed, and the next run raised ModuleNotFoundError on the same machine. Two interpreters, one install, and the variable your script checks is the one the interpreter never sets.

5

Python stdlib: the datetime json.dumps Refused to Write

A script that totals minutes per day dies on the line that writes the report. Four stdlib modules carry it, and one TypeError stands in the way.

6

Python debugging: the script that exits 0 with the wrong total

A totals script runs clean, prints a number, and the number is wrong. With no traceback to follow, you stop the program at the line that writes the value and read the dict from pdb.

For developers who learn by struggling

© 2026 Inva.dev.