Interfaces and Python

Type:
Talk
Audience level:
Intermediate
Category:
Best Practices/Patterns
March 9th 2:40 p.m. – 3:20 p.m.

Description

In 2.6, Python introduced the Abstract Base Classes. Before that we had "protocols" (and we still do). In this talk we'll look at how the general concept of interfaces fits into today's Python. We'll also look at some of the alternate proposals of the past, some of the controversies around ABCs, and the direction interfaces might go in the future.

Abstract

Talk Outline:

  1. What are Interfaces? (3 min)
    • modeling strict abstraction
    • precedents in other languages
  2. Interfaces in Python (6 min)
    • duck-typing
    • Python "protocols"
    • past proposals (PEP 245)
    • how Python "interfaces" are different
  3. Newer Interface Support (11 min)
    • annotations
    • Abstract Base Classes
    • why run-time validation?
    • ABC vs. duck-typing
  4. Third-party Libraries (5 min)
    • Peak's PyProtocols
    • zope.interface
    • Twisted
  5. What Next? (3 min)
    • strict interfaces
    • compile-time validation
    • an example interface library

For more comprehensive coverage of interfaces in Python, check out this reference.