When should I define a class Python?

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.

Sizin İçin Seçtik  How do you create a class of employee and initialize its members in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *