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

Setup#

Day 1: Basics#

Datatypes#

Exercises#

More About Datatypes#

Control Flow, Sequences, Iteration#

Exercises#

Day 2: Towards Real Programming#

Cleanup Mess From Yesterday#

All participants know, from other programming languages they speak, what a function is. A didactical masterpiece, at the end of yesterday’s course, was to show a Python generator before showing what a Python function is. Ah yes, comprehension had also confused people. Now, at 8am, with fresh minds in the audience, lets clear this up.

Functions#

Exercises#

File IO, Encoding#

Exercises#

Modules#

Project Management, Testing#

From Python: Project/Package Management:

Afternoon Hacking, Test Driven Development (Exercises)#

From From dict Records To Simple (Data) Classes:

Classes: Introduction#

From Object Oriented Programming

Day 3: More OO, Advanced Stuff#

Morning Wakeup (At 7am 🤨)#

Duck Typing: Good? Bad?#

  • Classes everywhere

    • Functions are callable: f.__call__()

    • Generators

      >>> x = g()
      >>> type(x)
      <class 'generator'>
      
      • Iterable: anything that has __iter__() (and __next__(), on the iterator)

    • Classes/types are callable: Person.__call__()instantiation of a type

    • Modules

      >>> import sys
      >>> type(sys)
      <class 'module'>
      
  • And inheritance? No:

    • File-like: anything that behaves like a file (see, for example, io.StringIO)

    • Callable

    • Iterable

Context Managers (with)#

We’ve been using the with statement lately for file I/O. Lets have a quick look at what that is …

OO, Continued (And Exceptions)#

Exception are classes too; every exception has its place in an entire hierarchy starting at BaseException.

Exercises#

Lets use classes in our exercise project that we started yesterday.

Random Cool Things#

*args And **kwargs, Closures, Decorators, …#

Batteries Included: Tour Through The Standard Library#

I strongly expressed my enthusiasm for asyncio, but this would probably justify a course of its own.

One question was if there was anything to build ASCII art GUIs, though, and I was quick to show Textualize (which is an asyncio user btw).