Last active
December 12, 2020 21:27
-
-
Save pybites/749358550803b24018b15cf7dab04b21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from datetime import datetime | |
>>> def today(dt=datetime.now()): | |
... print(dt) | |
... | |
>>> today() | |
2020-12-12 22:18:26.432268 | |
# oops | |
>>> today() | |
2020-12-12 22:18:26.432268 | |
>>> today() | |
2020-12-12 22:18:26.432268 | |
>>> from datetime import datetime | |
>>> def today(dt=None): | |
... if dt is None: | |
... dt = datetime.now() | |
... print(dt) | |
... | |
>>> today() | |
2020-12-12 22:19:11.617223 | |
# better | |
>>> today() | |
2020-12-12 22:19:12.545453 | |
>>> today() | |
2020-12-12 22:19:14.145179 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment