Files
This week we’re dealing with files. Files are one way to make data persistent - to store data separately from the program, which the program can then access. Files can also be a useful way to separate content (data) from the workings of the program (code).
Readings
- Python File Operation
- Think Python, Chapter 14: Files – Read through 14.4. Stop at 14.5: Catching Exceptions
Also, please re-read (skim) the following readings about dictionaries:
- Using dictionaries to store data as key-value pairs
- Think Python, Chapter 11 - Dictionaries – skim up to “11.6 Memos”
Summary
For this week’s summary, think about what you already know about other ways of storing data in Python, like variables, lists, and dictionaries. How are files different?
Summary prompt: What kinds of data do you think might be useful to store in a file? Why would you want to use a file rather than storing data in a variable inside of a program?
Question
As per usual, your question can be one of three types:
- Confusion: what didn’t you understand in the readings?
- Curiousity: what do you want to know more about?
- Connection: how does this topic connect to your own experiences?
Submit your summary+question on D2L under Quizzes before class starts on Tuesday.