# import datetime as dt

By Saurabh Kumar · TIL note, Jul 11, 2026 · Tags: python

Source: https://saurabh-kumar.com/til/1783771200/

Python 3.15 datetime docs now officially recommend [`import datetime as dt`](https://docs.python.org/3.15/library/datetime.html#module-datetime:~:text=Tip%20import%20datetime%20as%20dt) in a Tip block, to disambiguate the module from the `datetime.datetime` class. The tip cites [Adam Johnson's 2019 post](https://adamj.eu/tech/2019/09/12/how-i-import-pythons-datetime-module/) — 6 years from community convention to CPython docs. Fixes both traps: `from datetime import datetime` shadows the module, and `import datetime` reads ambiguously as `datetime.datetime.now()`. [via](https://fosstodon.org/@adamchainz/116897748723239892)
