Hacker News new | past | comments | ask | show | jobs | submit login

The comparison is being done between x_ts, which is a float, and x, which is a datetime object. Call be crazy but I think allowing this comparison to begin with is the problem.

    >>> from datetime import datetime
    >>> ts = 1571595618.0
    >>> x = datetime.utcfromtimestamp(ts)
    >>> x_ts = x.timestamp()
    >>> type(x_ts)
    <class 'float'>
    >>> type(x)
    <class 'datetime.datetime'>



The code in the first example says `ts == x_ts`, not `ts == x`.


Argh.


That's not the code from the article. The code in the article is comparing 2 floats. Though, equality operator would return `False` for comparison `x == x_ts` as well, instead of throwing an exception.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: