Skip to content

Commit ef016cb

Browse files
committed
Improved comments
1 parent 7dc9d26 commit ef016cb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

buzzlevel.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self):
4242
self._level = 0 # beep level initialized to 0
4343
self._active = False # object active state initialized to False
4444
self.run() # activate object
45-
45+
4646
def _beep(self, on):
4747
"""Beeps the buzzer once followed by a silence.
4848
@@ -68,7 +68,8 @@ def _beepLevel(self):
6868

6969
def run(self):
7070
"""Launches the _run method in a dedicated thread so it can run in the
71-
background while the calling program continues."""
71+
background while the calling program continues.
72+
"""
7273

7374
if not self._active:
7475
thread1 = threading.Thread(target = self._run, args = [])
@@ -89,10 +90,10 @@ def setLevel(self, level):
8990
level: the number of beeps to be produced (0 to 4)
9091
"""
9192
try:
92-
if type(level) != int:
93+
if type(level) != int: # check that level is an integer
9394
raise TypeError("level must be an integer.")
94-
elif level >=0 and level <= 4:
95-
self._level = level
95+
elif level >=0 and level <= 4: # check that level is between 0 and 4
96+
self._level = level # set _level attribute
9697
else:
9798
raise ValueError("level must be between 0 and 4.")
9899

0 commit comments

Comments
 (0)