[Python-Dev] PEP 495 Was: PEP 498: Literal String Interpolation is ready for pronouncement

Tim Peters tim.peters at gmail.com
Sun Sep 13 17:44:13 CEST 2015


[Chris Angelico <rosuav at gmail.com>]
> What I'd like to hear (but maybe this won't be possible) would be
> "less-than is transitive if and only if <X>", where <X> might be
> something like "all of the datetimes are in the same timezone" or
> "none of the datetimes fall within a fold" or something. That would at
> least make sorting possible, but maybe with a first-pass check to
> ensure transitivity.
>
> Vain hope or plausible restriction?

Pragmatically, if someone needs to care about sorting aware datetimes
that may include times in folds, the obvious way is to convert them to
UTC first (which can be done with sort's `key=` argument).  Times in
UTC are totally ordered (essentially the same as working with
integers).

That's a sane & easy sufficient condition.  It's a waste of time to
worry about minimal necessary conditions.  "Convert to UTC' is the
obvious way to do darned near everything.  Converting to any other
fixed-offset zone would do just as well, but _that_ observation is
also a waste of time, since "convert to UTC" is just as easy ;-)


More information about the Python-Dev mailing list