Surprising find for me, I thought I’d document it here for future reference.

It appears in python, datetime.time(0,0,0) evaluates to False

So, (and this is a pattern I have used a time or two) if you are doing something like:

current_checkin = get_current_checkin(user) if current_checkin.checkout_time: create_new_checkin() else: return "You have to check out before checking in again!"

This will fail if checkout_time = 12:00 am

This didn’t actually happen to me, another developer discovered it.

I always use datetime.datetime() 🙂