13.2 Introduction

So far, the programs we have written have a beginning, a middle, and an end. We know the order in which things will happen because we have implemented the steps in a linear fashion. That is not the way most programs work. Think of the programs you use on a daily basis—from your web browser and word processor to video games. These programs do not have a beginning, a middle, and an end. Instead, they sit there and wait for you to click your mouse, touch your screen, or press a key. When you take some action, the program responds with its own action. The order of the actions is determined by you, not the program.

13.2.1 Event-Driven Programming

Programs that wait for an event to occur and then respond to that event by taking ...

Get Python Programming in Context, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.