Python time comparison
Question: How do I compare times in python?

I see that date comparisons can be done and there's also "timedelta", but I'm
struggling to find out how to check if the current time (from datetime.now())
is earlier, the same, or later than a specified time (e.g. 8am) regardless of
the date.


Answer: You _can't_ compare a specific point in time (such as "right now") against an
unfixed, recurring event (8am happens every day).

You can check if now is before or after _today's_ 8am:

    
    
    >>> import datetime
    >>> now = datetime.datetime.now()
    >>> today8am = now.replace(hour=8, minute=0, second=0, microsecond=0)
    >>> now < today8am
    True
    >>> now == today8am
    False
    >>> now > today8am
    False
    

