【发布时间】:2013-06-08 14:23:35
【问题描述】:
我是 Python 的新手,我使用的是 Python 3.3.1。
class Parent: # define parent class
parentAttr = 100
age = 55
def __init__(self):
print ("Calling parent constructor")
def setAttr(self, attr):
Parent.parentAttr = attr
class Child(Parent):
def childMethod(self):
print ('Calling child method')
现在我将创建
c=child
c.[here every thing will appear methods and attr (age,setAttr)]
如何区分方法和属性?我的意思是,我什么时候使用c.SetAtrr(Argument) 和c.SetAtrr=value?
【问题讨论】:
-
类文档应该告诉您哪些属性是要调用的方法,哪些是您可以安全更改其值的属性。