Modules and Packages
Stop writing everything in one file. You'll import modules from Python's standard library, split your own code into modules and a package, and use the line that lets a file be both a program and a module. Then you'll make a virtual environment, install packages with pip and record them in requirements.txt, and build a toolkit for game night.
Updated
Modules in Python
- import and the Standard Library (Apprentice): Python comes with a standard library of ready-made modules for dice rolls, dates, averages and more, and an import line brings one into your program, whole, by its names, or under a shorter name.
- Your Own Modules and Packages (Apprentice): Any .py file is a module another file can import, so a growing program is split into files by job, a folder of them with __init__.py becomes a package, and the __name__ check keeps a file's own test lines from running when it's imported.
Packages and Virtual Environments
- Virtual Environments and pip (Apprentice): A virtual environment gives each Python project its own private set of packages, pip installs packages into it from PyPI, and a requirements.txt with exact versions lets any computer install the same set with one command.
Exercise: Game Night Toolkit
- Exercise: Game Night Toolkit (Apprentice): Finish a game night package of modules, dice and scores, keep a try-out line from running on import, connect the modules with import lines, and run it all from its own virtual environment with pinned requirements.