Some one to help me this, What is the difference between an object property and type property? if possible with an example in python.. thanks!
有人帮我这个,对象属性和类型属性有什么区别?如果可能的话,在python中有一个例子..谢谢!
1 个解决方案
#1
4
class A:
class_property = 10
def __init__(self):
self.object_property = 20
The difference is that you can access class_property through class A:
不同之处在于您可以通过A类访问class_property:
print A.class_property
but you can access object_property only through an instance of A:
但是你只能通过A的实例访问object_property:
a = A()
print a.object_property
#1
4
class A:
class_property = 10
def __init__(self):
self.object_property = 20
The difference is that you can access class_property through class A:
不同之处在于您可以通过A类访问class_property:
print A.class_property
but you can access object_property only through an instance of A:
但是你只能通过A的实例访问object_property:
a = A()
print a.object_property