datetime.time and midnight

D'Arcy J.M. Cain darcy at druid.net
Sun Feb 22 10:10:19 EST 2009


On Sun, 22 Feb 2009 05:20:31 -0200
"Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> wrote:
> En Sat, 21 Feb 2009 21:55:23 -0200, MRAB <google at mrabarnett.plus.com>  
> escribió:
> > I think it's because midnight is to the time of day what zero is to
> > integers, or an empty string is to strings, or an empty container ...
> 
> So chr(0) should be False too...

>>> chr(0)
'\x00'

That's not an empty string.  This is like...

>>> bool([0])
True

Now if Python had a char type one might expect the zero char to be
False but a collection of anything, even if the elements are False, is
not empty and hence is True.

As someone else said, there's not much point in casting time to boolean
but if you do, it is a base type, not a sequence so I wouldn't expect
to apply sequence logic to the outcome.

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list