Functions are objects, too
There are numerous situations where we'd like to pass around a small object that is simply called to perform an action. In essence, we'd like an object that is a callable function. This is most frequently done in event-driven programming, such as graphical toolkits or asynchronous servers; we'll see some design patterns that use it in Chapter 11, Common Design Patterns, and Chapter 12, Advanced Design Patterns.
In Python, we don't need to wrap such methods in a class definition because functions are already objects! We can set attributes on functions (though this isn't a common activity), and we can pass them around to be called at a later date. They even have a few special properties that can be accessed directly.
Here's yet another contrived example, sometimes used as an interview question:
>>> def fizz(x: int) -> bool:
... return x % 3 == 0
>>> def buzz(x: int) ->...