When should I be using classes in Python?

后端 未结 5 1979
星月不相逢
星月不相逢 2020-11-28 17:21

I have been programming in python for about two years; mostly data stuff (pandas, mpl, numpy), but also automation scripts and small web apps. I\'m trying to become a bette

5条回答
  •  臣服心动
    2020-11-28 17:59

    I think you do it right. Classes are reasonable when you need to simulate some business logic or difficult real-life processes with difficult relations. As example:

    • Several functions with share state
    • More than one copy of the same state variables
    • To extend the behavior of an existing functionality

    I also suggest you to watch this classic video

提交回复
热议问题