Collections and Generics

Collections and Generics#

Learning Objectives#

After working through this topic, you should be able to:

  • Type lists, dicts, tuples, and sets with their element types

  • Understand the difference between concrete and abstract collection types

  • Use the Python 3.12+ generic syntax for type-preserving functions and classes

  • Type callable objects (functions as arguments)

  • Understand how type narrowing works with isinstance checks

Materials#

Download the slides.

Quiz#