On Sun, Aug 4, 2019 at 12:36 PM Hongyi Zhao <hongyi.z...@gmail.com> wrote: > > Hi, > > I read the code here: > > https://github.com/shichao-an/homura/blob/master/homura.py > > > It said in line 244: > > duration = time.time() - self.start_time + 1 > > I'm very confusing why it used like this instead of the following: > > duration = time.time() - self.start_time > >
My guess is that it's an easy way to ensure that you never divide by zero (assuming monotonic time, which time.time() doesn't guarantee). On systems where the normal "get time" function returns an integer of seconds, adding one also forms an easy way to "round up" and include both the starting second and the ending second; but in Python, you get a float with subsecond resolution, so that doesn't really apply. BTW, I was somewhat amused to see a question about TIME in a file named "Homura". Turns out that it actually IS named after who I think it is. Hah. ChrisA -- https://mail.python.org/mailman/listinfo/python-list