Python 3 Class and Instance attributes

CLASS ATTRIBUTES VS INSTANCE ATTRIBUTES:

  • Class attributes: Instances inherit all class attributes, but we don’t always want to modify all the instances attributes, so it is useful in some cases to deal with instances attributes.
  • Instances attributes: Are specific to each object, are easy to manipulate. They only live while the object lives. The drawback is that they don’t allow to keep track of values between instances, also the values are destroyed if the object is destroyed.

Pythonic way to create them:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store