[Python-ideas] Please reconsider the Boolean evaluation of midnight
Tim Peters
tim.peters at gmail.com
Thu Mar 6 18:05:39 CET 2014
[Alexander Belopolsky <alexander.belopolsky at gmail.com>]
> I have to admit that before this discussion, I did not know about the
> following consequence of the documented behavior:
>
>>>> from datetime import *
>>>> t = datetime(2014, 1, 1, tzinfo=timezone.utc)
>>>> tz1 = timezone(timedelta(hours=5))
>>>> tz2 = timezone(timedelta(hours=-5))
>>>> bool(t.timetz())
> False
>>>> bool(t.astimezone(tz1).timetz())
> False
>>>> bool(t.astimezone(tz2).timetz())
> True
I'm not sure I did either! An "aware" time object is a bizarre beast,
and I've never used one outside of writing datetime test cases. I'm
not even sure why aware time objects exist - we'd have to dig into
Guido's subconscious for that one ;-)
More information about the Python-ideas
mailing list