[New-bugs-announce] [issue28878] datetime should not be a subclass of date

sergem report at bugs.python.org
Mon Dec 5 07:52:20 EST 2016


New submission from sergem:

I have Python 3.5.2.

datetime is implemented as a subclass of date
(isinstance(datetime.datetime(2015,1,1), datetime.date) == True)

I suppose that violates Liskov substitution principle:

1. datetime and date cannot be compared via "<".
2. both of these classes have "isoformat()" method. And the meaning of these methods differ.

It means one cannot pass datetime to the function that expects date.

Also one cannot say that datetime "is a" date. 

I suppose datetime must not be a subclass of date.

----------
messages: 282416
nosy: sergem
priority: normal
severity: normal
status: open
title: datetime should not be a subclass of date
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28878>
_______________________________________


More information about the New-bugs-announce mailing list