The difference between an object property and a type property

Someone to help me, What is the difference between an object property and a type property? if possible with an example in python .. thanks!

+3
source share
1 answer
class A:
   class_property = 10

   def __init__(self):
      self.object_property = 20

The difference is that you can access the property class through class A:

print A.class_property

but you can only access object_property through instance A:

a = A()
print a.object_property
+4
source

Source: https://habr.com/ru/post/1775604/


All Articles