-1
我正在阅读python tutorial。Python方法名称和变量名称关系
变量名称pinA
与方法名称getPinA()
有什么关系,它与scala中的自动getter setter类似。
class BinaryGate(LogicGate):
def __init__(self,n):
LogicGate.__init__(self,n)
self.pinA = None
self.pinB = None
def getPinA(self):
return int(input("Enter Pin A input for gate "+ self.getLabel()+"-->"))
def getPinB(self):
return int(input("Enter Pin B input for gate "+ self.getLabel()+"-->"))
不,它不需要。向下滚动到底部并查看完整的代码。 –
另外,FWIW,Python指南建议'naming_like_this'而不是'namingLikeThis' –