ВНИМАНИЕ: Я изучаю Python на все 10 минут, поэтому приношу извинения за любые глупые вопросы!Python: проблема с перегруженными конструкторами
Я написал следующий код, но я получаю следующее исключение:
Message File Name Line Position Traceback Node 31 exceptions.TypeError: this constructor takes no arguments
class Computer:
name = "Computer1"
ip = "0.0.0.0"
screenSize = 17
def Computer(compName, compIp, compScreenSize):
name = compName
ip = compIp
screenSize = compScreenSize
printStats()
return
def Computer():
printStats()
return
def printStats():
print "Computer Statistics: --------------------------------"
print "Name:" + name
print "IP:" + ip
print "ScreenSize:" , screenSize // cannot concatenate 'str' and 'tuple' objects
print "-----------------------------------------------------"
return
comp1 = Computer()
comp2 = Computer("The best computer in the world", "27.1.0.128",22)
Есть мысли?
См. Http://stackoverflow.com/questions/92230/python-beyond-the-basics –