Whenever you need to maintain a state of your functions and it cannot be accomplished with generators (functions which yield rather than return). Generators maintain their own state. If you want to override any of the standard operators, you need a class.
Read moreIs __ init __ necessary in Python class?
No, it isn’t necessary .
Read moreHow do you initialize a class in Python?
To create instances of a class, you call the class using class name and pass in whatever arguments its __init__ method accepts .
Read more