开发者

difference between an object property and type property

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜