开发者

difference between an object property and type property

开发者 https://www.devze.com 2023-01-25 22:16 出处:网络
Some one to help me this, What is the difference between an object pr开发者_Go百科operty and type property? if possible with an example in python.. thanks!class A:

Some one to help me this, What is the difference between an object pr开发者_Go百科operty and type property? if possible with an example in python.. thanks!


class A:
   class_property = 10

   def __init__(self):
      self.object_property = 20

The difference is that you can access class_property through class A:

print A.class_property

but you can access object_property only through an instance of A:

a = A()
print a.object_property
0

精彩评论

暂无评论...
验证码 换一张
取 消