No Boolean type in "types"
Mikael Olofsson
mikael at isy.liu.se
Tue Jun 13 07:33:26 EDT 2000
On 13-Jun-00 Thomas Mangin wrote:
> Can someone explain me why the module "types" have no boolean type defined
> ?
Probably because there is no boolean type. Anything empty or zero is
considered false, and anything else is considered true.
Exampes:
0, '', [], {} are all false
1, ' ', [0], {'false':0} are all true
You can tamper with your own classes to make instances be considered
true or false, to your liking. See the manual.
IIRC,
true = (0==0)
false = not true
would actually give you the integers 1 and 0 in the current
implementation.
/Mikael
-----------------------------------------------------------------------
E-Mail: Mikael Olofsson <mikael at isy.liu.se>
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date: 13-Jun-00
Time: 13:23:35
This message was sent by XF-Mail.
-----------------------------------------------------------------------
More information about the Python-list
mailing list