May 2021
Intermediate to advanced
142 pages
3h 37m
English
Few things are more destructive for a code base then a programmer operating under flawed assumptions. We want to write code that makes it clear to others what calling a piece of code does and what effects it might have.
In an earlier chapter, you learned how to use flake8 to catch certain types of errors before you even run your Python code. One of the dangerous classes of errors that flake8 helps you avoid is variable shadowing from * (“wildcard”) imports.
Consider the following toy file that provides two methods for managing dinosaurs:
| | from veterinarian import * |
| | from lab import * |
| | |
| | def euthanize_dinosaurs(): |
| | for dinosaur in get_dinosaurs(): |
| | print(f"Euthanizing ... |