J
Jacob H
Hello all,
I'm close to being a novice programmer and I never was good at math.
So I'm curious to know ways in which this following code can be made
more efficient, more elegant. The code just calculates and displays
elapsed wall clock seconds since initialization.
class ExampleTimer:
def __init__(self):
self.start = time.clock()
def run(self):
while 1:
now = time.clock()
allseconds = int(now) = int(self.start)
seconds = 0
minutes = 0
hours = 0
for n in range(1, (allseconds + 1)):
seconds += 1
if n % 60 == 0:
minutes += 1
seconds = 0
if n % 3600 == 0:
hours += 1
minutes = 0
print "%s hrs %s min %s sec" % (hours, minutes, seconds)
time.sleep(1)
app = ExampleTimer()
app.run()
I am grateful for any suggestions and advice.
Jake
I'm close to being a novice programmer and I never was good at math.
So I'm curious to know ways in which this following code can be made
more efficient, more elegant. The code just calculates and displays
elapsed wall clock seconds since initialization.
class ExampleTimer:
def __init__(self):
self.start = time.clock()
def run(self):
while 1:
now = time.clock()
allseconds = int(now) = int(self.start)
seconds = 0
minutes = 0
hours = 0
for n in range(1, (allseconds + 1)):
seconds += 1
if n % 60 == 0:
minutes += 1
seconds = 0
if n % 3600 == 0:
hours += 1
minutes = 0
print "%s hrs %s min %s sec" % (hours, minutes, seconds)
time.sleep(1)
app = ExampleTimer()
app.run()
I am grateful for any suggestions and advice.
Jake