Finally got around to dealing with one of those "DeprecationWarning: datetime.datetime.utcnow() is deprecated" warnings, so I wrote it up as a tiny TIL:
til.simonwillison.net/python/u

Follow

@simon You may also want to note that this changes the semantics of your `datetime` object, which is why we didn't just make `datetime.utcnow()` an alias for `datetime.now(UTC)`. If you change it you have to change it everywhere, and make sure all the datetimes you are consuming from other libraries are also aware.

(Also in the second example you have `import python` instead of `import datetime`).

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.