This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yurzo
Recipients yurzo
Date 2020-10-01.15:54:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1601567658.27.0.420109981563.issue41904@roundup.psfhosted.org>
In-reply-to
Content
Last night I discovered we have datetime.datetime.today alongside
datetime.datetime.now and datetime.date.today.

- datetime.now
- date.today

Both make semantic sense.

datetime.datetime.today returns a datetime, which make no semantic sense and causes confusion.

On further inspection of the code, this is due to the fact that datetime inherits from date.

so datetime.today is practically an implementation of datetime.now minus the "tz".

I think we should implement a datetime.today only to rise an AttributeError or some other way to stop people from using the wrong semantic mental model.
We'd also need to remove the documentation entry: 
https://docs.python.org/3/library/datetime.html#datetime.datetime.today


From this inspection we also find that:

datetime.hour/minute/second are unnecessarily redefined.
lines Lib/datetime.py#L1606 to datetime.py#L1620

could be removed without any ill effect.






date.today:
https://github.com/python/cpython/blob/256e54acdbdb26745d4bbb5cf366454151e42773/Lib/datetime.py#L833



https://docs.python.org/3/library/datetime.html#datetime.datetime.today
History
Date User Action Args
2020-10-01 15:54:18yurzosetrecipients: + yurzo
2020-10-01 15:54:18yurzosetmessageid: <1601567658.27.0.420109981563.issue41904@roundup.psfhosted.org>
2020-10-01 15:54:18yurzolinkissue41904 messages
2020-10-01 15:54:18yurzocreate