Week 9

Et cetera

A few smaller tools show up everywhere after this: a set, type hints, extra arguments, and a compact way to build a list.

A set keeps values with no duplicates and no order you should rely on. Global is a name that lives outside every function. Constants are names you promise not to change, written in capitals by convention. Type hints say what kind of value you meant. Mypy can check those hints. Docstrings are the sentences at the top of a function that tell a reader what it is for.

Argparse reads command-line words for you. Unpacking pulls a list or a dict apart into names. *args collects extra positional arguments. **kwargs collects extra named ones. Map, filter, and comprehensions build a new list from an old one in one expression. Enumerate gives you the index and the item together. A generator yields one value at a time instead of building the whole list first.

A fresh example: turn a list of words into a list of their lengths with a comprehension, then into a set so repeated lengths appear once. None of that is the final project.

The idea
Tools you will keep meeting A set Type hints Extra arguments A compact list

Then the final project

Final project. A Python program of your own, bigger than one problem set. The spec lists the files. The idea is yours.