WARNING: I have been learning Python for all of 10 minutes so apologies for any stupid questions!
I have written the following code, however I get the following exception:
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)
Any thoughts?
I’m going to assume you’re coming from a Java-ish background, so there are a few key differences to point out.