On Thu, Jan 29, 2015 at 11:19 AM, Yawar Amin <yawar.amin@gmail.com> wrote:My test implementation works for me on Python 2.7, see http://repl.it/9Wzcool site!And yes, it does appear to work.However the subclassing approach is really weird, as the infinite datetimes have a year, month, day, etc -- that strikes me as ripe for error. That's why I didn't subclass, but just had them e independent.Another option would be to override just about everything...-ChrisNotice especially the last few assertions, where normal datetime objects are on the LHS.Regards,YawarOn Wed, Jan 28, 2015 at 6:55 PM, Yawar Amin <yawar.amin@gmail.com> wrote:Cool, the comparison operator logic looks very similar to mine:
https://groups.google.com/d/msg/python-ideas/G3jeWoa6h14/ELpDLFu28QcJ
Did you get it to work both ways? i.e.datetime.neg_inf < datetime.now()and
datetime.now() > datetime.neg_infI had trouble with that, because the regular datetime doesn't know how to compare itself to a neg_inf object.
I believe the ideal design is the following type hierarchy:
datetime_base
datetime_neg_inf
datetime_pos_inf
datetime
But in the interests of pragmatism, I think this one can be made to
work:
datetime
datetime_neg_inf
datetime_pos_infyup -- should work.and you could add class methods to the datetime object, so you could do:datetime.neg_inf()anddatetime.pos_inf()Theadvantage to this is that we don't have to switch everything over to
using a new derived type--just use the normal datetime for the majority
of cases where we don't need inifinity dates.And it could be a third part package, too. -- particularly good for backward compatibility.-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov