Classes are a way to bundle functionality and state together.
A "type" and a "class" are interchangeable terms in Python:
bool are all classes.
Depending on what you're doing, you might be able to get away with writing quite a bit of Python code without ever creating a class.
You'll certainly use quite a few classes in Python (remember types are classes) but you may not need to create your own often.
Classes in Python have quite a few features that are missing from some other programming languages.
Python's classes use
__dunder__ methods to allow for operator overloading and implementing interfaces ("protocols" as they're usually called in the Python world) such as the iterator protocol, the context manager protocol, or the descriptor protocol.
Need to fill-in gaps in your Python skills? I send regular emails designed to do just that.
Sign up for my Python tips emails and I'll share my favorite Python insights with you every couple weeks.
Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.