From the course: Programming Concepts for Python
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Event-driven programming - Python Tutorial
From the course: Programming Concepts for Python
Event-driven programming
- Using the polling method to check for the pizza delivery wasn't very efficient. And it was pretty exhausting running up and down those stairs. Luckily, there's a better way to wait for the pizza guy: event-driven programming. I can just lay here on the bed waiting for an event to occur. And when that event finally does occur, it'll interrupt my waiting state, and only then will I have to get up off the bed to handle that event with the appropriate action. There are a lot of different types of events that I'm prepared to handle. One example is a timer event. The pizza company promises that they'll deliver the pizza in 30 minutes or less, and I've decided to give them a few minutes of slack, so I've set a timer for 45 minutes. And if I haven't received my pizza by then, I should probably give them a call to see if there's a problem with the order. (timer ringing) Now that the timer event has interrupted my waiting…