Need way to check if a `datetime.timedelta` is positive

Nov. 5, 2011
2:07 p.m.
(Sorry for possible double-post, Google Groups was doing weird things.) Hey, I'm currently writing code that's manipulating `datetime.timedelta` objects. I get one and I need to check whether it's positive or negative. I can't really think of an elegant way to do this. Here's one: my_timedelta >= datetime.timedelta(0) Another one: my_timedelta.total_seconds() >= 0 Perhaps we should allow a more elegant way? Possibly `my_timedelta >= 0` for 0 only? Thanks, Ram.
4883
Age (days ago)
4883
Last active (days ago)
3 comments
4 participants
participants (4)
-
Arnaud Delobelle
-
cool-RR
-
Ram Rachum
-
Terry Reedy