MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / Timer

Class Timer

example_code/item_047.py:148–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147print("Example 5")
148class Timer:
149 def __init__(self, period):
150 self.current = period
151 self.period = period
152
153 def reset(self):
154 print("Resetting")
155 self.current = self.period
156
157 def tick(self):
158 before = self.current
159 self.current -= 1
160 return before
161
162 def __bool__(self):
163 return self.current > 0
164
165
166print("Example 6")

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected