§ 2.12section 12 of 20·~3 min
Check your understanding
- What three methods does
@dataclasswrite for you? - Why is
availablea@propertyrather than a normal attribute? - What's the difference between a module and a package?
- Why is a generator memory-efficient?
- Why should every test get a fresh fixture?
Answers
__init__,__repr__and__eq__.- It's calculated from
issued_toevery time, so it can never go out of sync. - A module is one
.pyfile. A package is a folder of modules with an__init__.py. - It produces one value at a time on demand, instead of holding the whole sequence in memory.
- So one test's changes (issuing a book, say) can't make another test pass or fail. Tests must be independent and run in any order.
Now take the quiz. The pass mark is 7/10.
LABAIE-102· hands-on
Library lets members borrow forever
Fix a real ticket in a small codebase you didn't write: read the code, change only the functions you're given, pass the tests, then submit for hidden checks and a score.
Open the lab →