Agenda: Python (2025-10-13 - 2025-10-15)#

Idea is to quickly go over Python basics (variables, datatypes, functions, …) on day 1. Then, on day 2, launch a group exercise to make something bigger (see Exercise Kick Off). The remaining material (OO etc., read below) is then covered in support of making something bigger.

Setup#

Basics#

Datatypes#

Exercises#

More On Datatypes#

Control Flow, Sequences, Iteration#

Exercises#

Functions#

From Functions:

Exercises#

Lets keep the following topics in mind, but defer them until later.

File IO#

Exercises#

Exercise Kick Off#

Note

This exercise (a data logger) is not set in stone. What makes it ideal is that it gives us much opportunity to cover the remaining topics.

Based upon what we have learned, we are ready to enter a larger exercise. Starting with one exercise where each participant is on their own, straightforwardly hack a “data logger” that reads from a number of named input sensors and writes a CSV file.

Future

  • Turn inputs (sensors) and outputs (CSV and …) into something more flexible (⟶ OO)

  • Unit testing

  • Project management and packaging

Modules#

(Exercise: split monolithic data logger into something more approachable)

Object Oriented Programming, And Exceptions#

From Object Oriented Programming

Exceptions too,

Exercise: OO#

  • Add more outputs; for example …

  • Polymorphic sensor

    • One that receives UDP datagrams asynchronously (⟶ Multithreading)

    • One over userspace I2C? (here)

  • “Main Loop” object

    • configurable interval

    • graceful termination

    • time (and interval) abstracted away with a generator?

Project Work: Virtual Environments, Unit Testing, Packaging, PyPI#

From Python: Project/Package Management,

Optional Topics#

  • Using matplotlib to draw graphs from gathered data

  • Data analysis using pandas

  • Automation using subprocess and shutil