Class And Instance Attributes

What is Object Oriented Programming (OOP):

OOP

Instance Attribute:

Instance attribute
foo = MyClass(2)
foo.class_var
## 1
foo.class_var = 2
foo.class_var
## 2
MyClass.class_var
## 1

Class Attribute:

Class attribute
foo = MyClass(2)
foo.class_var
## 1
MyClass.class_var = 2
foo.class_var
## 2

Differences Between Class and Instance Attributes:

# #

What are the advantages and drawbacks of each of them:

+ And -

How does Python deal with the object and class attributes using the __dict__:

In conclusion:

--

--

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