simpler increment of time values?
rosuav at gmail.com
Thu Jul 5 19:16:16 CEST 2012
On Fri, Jul 6, 2012 at 3:06 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> The "+ 86400" is redundant; you'll get the same answer with or without
> it. There is nothing to fear from going negative when doing modulo
> arithmetic, because unlike C, Python actually has well-defined
> semantics regarding modulo division of negative numbers.
>>>> (13382 + 86400 - 42597) % 86400
>>>> (13382 - 42597) % 86400
Ah good. There's a lot of languages like that these days, but I've
gotten so into the habit of not depending on it that I just
automatically add N first. It's redundant but insignificant.
So it's even easier than I said. And bonus lesson for the day: Try
things in the interactive interpreter before you post. :)
More information about the Python-list