Re: datetime as subclass of date

2014-01-24 Thread Skip Montanaro
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

Re: datetime as subclass of date

2014-01-23 Thread Ben Finney
Roy Smith writes: > Ben Finney 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 shou

Re: datetime as subclass of date

2014-01-23 Thread Roy Smith
In article , Ben Finney wrote: > Skip Montanaro 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

Re: datetime as subclass of date

2014-01-23 Thread Ben Finney
Skip Montanaro 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 t

datetime as subclass of date

2014-01-23 Thread Skip Montanaro
This took my by surprise just now: >>> import datetime >>> now = datetime.datetime.now() >>> isinstance(now, datetime.datetime) True >>> isinstance(now, datetime.time) False >>> isinstance(now, datetime.date) True >>> issubclass(datetime.datetime, datetime.date) True I'd never paid any attention