Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64640 > unrolled thread
| Started by | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| First post | 2014-01-24 09:14 +1100 |
| Last post | 2014-01-24 10:03 -0600 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: datetime as subclass of date Ben Finney <ben+python@benfinney.id.au> - 2014-01-24 09:14 +1100
Re: datetime as subclass of date Roy Smith <roy@panix.com> - 2014-01-23 19:10 -0500
Re: datetime as subclass of date Ben Finney <ben+python@benfinney.id.au> - 2014-01-24 17:54 +1100
Re: datetime as subclass of date Skip Montanaro <skip@pobox.com> - 2014-01-24 10:03 -0600
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-01-24 09:14 +1100 |
| Subject | Re: datetime as subclass of date |
| Message-ID | <mailman.5913.1390515296.18130.python-list@python.org> |
Skip Montanaro <skip@pobox.com> writes: > […] I was asking [Python] if a datetime instance was an instance of a > date. Which, it turns out, it is. Yep. Makes sense, since ‘datetime’ can do everything ‘date’ can do, and is conceptually a subset of the same concept. The same is not true of the ‘time’ type from that module, by the way; it does not represent a specific point on the timeline. So ‘datetime’ inheriting from ‘time’ wouldn't make sense. Just in case anyone was wondering. -- \ “There is something wonderful in seeing a wrong-headed majority | `\ assailed by truth.” —John Kenneth Galbraith, 1989-07-28 | _o__) | Ben Finney
[toc] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-01-23 19:10 -0500 |
| Message-ID | <roy-29B820.19102323012014@news.panix.com> |
| In reply to | #64640 |
In article <mailman.5913.1390515296.18130.python-list@python.org>, Ben Finney <ben+python@benfinney.id.au> wrote: > Skip Montanaro <skip@pobox.com> writes: > > > […] I was asking [Python] if a datetime instance was an instance of a > > date. Which, it turns out, it is. > > Yep. Makes sense, since ‘datetime’ can do everything ‘date’ can do, and > is conceptually a subset of the same concept. That's reasonable, but given that, it's weird that date(2014, 1, 23) == datetime(2014, 1, 23) is False. You would think it should be True, in the same way that 1 + 0j == 1 is True.
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-01-24 17:54 +1100 |
| Message-ID | <mailman.5930.1390546479.18130.python-list@python.org> |
| In reply to | #64643 |
Roy Smith <roy@panix.com> writes: > Ben Finney <ben+python@benfinney.id.au> wrote: > > > Makes sense, since ‘datetime’ can do everything ‘date’ can do, and > > is conceptually a subset of the same concept. > > That's reasonable, but given that, it's weird that date(2014, 1, 23) == > datetime(2014, 1, 23) is False. You would think it should be True, in > the same way that 1 + 0j == 1 is True. Hmm. It does make sense to me that ‘datetime.date(2014, 1, 23) == datetime.datetime(2014, 1, 23)’. I can come up with rationalisations for why it isn't, but they're not satisfactory. I also don't consider it a bug, though. I'm conflicted :-) -- \ “Those who write software only for pay should go hurt some | `\ other field.” —Erik Naggum, in _gnu.misc.discuss_ | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Skip Montanaro <skip@pobox.com> |
|---|---|
| Date | 2014-01-24 10:03 -0600 |
| Message-ID | <mailman.5946.1390579404.18130.python-list@python.org> |
| In reply to | #64643 |
One thing that always reinforced my notion that issubclass(datetime.datetime, datetime.date) should be False is that the presence of of date and time methods gives me a mental image of delegation, not inheritance. That is, it "feels" like a datetime object is the aggregation of a date object and a time object, not a specialized date object with some added time machinery mixed in. Skip
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web