Organizing code
Comments from survey
- "It would be helpful to have slightly more guidance on the labs … maybe the tasks broken down into smaller steps."
- "I feel like I could use a python refresher"
- "I'd like there to be some notification if additional readings are added."
Grade breakdown tweaks
How have you been organizing code (in this course and before)?
…within files?
…between files?
Files! Things you import
!
-
Show Python's module search path.
import sys sys.path
-
Look in those directories.
-
Look at
csv.py
. -
Make a
csv.py
file the current directory.print("Aidan csv")
-
Try
import csv
.
Let's refactor phone code from last lecture.
Simulate an API call:
from time import sleep
sleep(5)
How do we keep the tests from being slow?
Folders!
How have you been organizing data?
a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data
Encyclopedia of Computer Science, 2003
What data structures exist in Python?
pytest --cov --cov-report html
open htmlcov/index.html
Not the Git kind