Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was familiar with the issue described, but it was useful to learn the shortcut of passing a timezone to `now()`, since I used to rely on `utcnow().replace()`, which was needlessly verbose.

    # what I used to do:
    >>> datetime.utcnow().replace(tzinfo=timezone.utc)
    # what I'll be doing from now on:
    >>> datetime.now(timezone.utc)


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

Search: