Skip to content

Latest commit

 

History

History
133 lines (75 loc) · 2.15 KB

lecture_06.md

File metadata and controls

133 lines (75 loc) · 2.15 KB

Lecture 6

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."


How have you been organizing code (in this course and before)?


…within files?


…between files?


Modules

Files! Things you import!


Search path

  1. Show Python's module search path.

    import sys
    sys.path
  2. Look in those directories.

  3. Look at csv.py.

  4. Make a csv.py file the current directory.

    print("Aidan csv")
  5. Try import csv.


Refactoring

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?


Packages

Folders!


How have you been organizing data?


Data structures

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?


Abstraction


Object-Oriented Programming (OOP)

Intro from Python course


Code/test coverage

pytest-cov


pytest --cov --cov-report html
open htmlcov/index.html

Branching

Not the Git kind



Revisit expectations