My code is:
import time
class Stopwatch (object):
def start (self):
self.beginningTime = time.time()
self.fehlerzahl = 1
def stop (self):
self.endTime = time.time()
self.time = self.endTime - self.beginningTime
def fehler(self):
self.fehlerzahl = self.fehlerzahl + 1;
def getTime (self):
return(self.time + self.fehlerzahl * 2)
When I call the fehler() (Function names are in German) funtction, python gives me the following error trace:
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import stopwatch
>>> c = stopwatch.Stopwatch()
>>> c.fehler()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "stopwatch.py", line 10, in fehler
self.fehlerzahl = self.fehlerzahl + 1;
AttributeError: 'Stopwatch' object has no attribute 'fehlerzahl'
>>>
Please tell me why it doesn't run.
Thanks