Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Equivalent code to the bool() built-in function Date: Tue, 19 Apr 2011 12:18:34 +1200 Lines: 19 Message-ID: <9142mtF51iU1@mid.individual.net> References: <4da9fb0b$0$13696$426a74cc@news.free.fr> <87k4etho6e.fsf@benfinney.id.au> <4daa2b72$0$32037$426a74cc@news.free.fr> <87d3klha85.fsf@benfinney.id.au> <4daaa6f6$0$20187$426a74cc@news.free.fr> <911dvfF6ocU1@mid.individual.net> <4dac97ca$0$10609$742ec2ed@news.sonic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 8J6RcU/a0gIDVaBtL2J2Ww3bgul3h+MsBN043/waJmBXpG6GSa Cancel-Lock: sha1:bkns4N0EkWVQUGSjH6mpv/DF+yQ= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: <4dac97ca$0$10609$742ec2ed@news.sonic.net> Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3511 John Nagle wrote: > Pascal got this right. (A nice feature of Pascal > was that "packed array of boolean" was a bit array). > C, which originally lacked a "bool" type, got it wrong. > So did Python. If Python had had a boolean type from the beginning, it probably wouldn't have been a subclass of int -- that was more or less forced by backwards compatibility issues. > Java is in the middle, with an isolated > "boolean" type but a system that allows casts. I'm not sure that's all that much different from Pascal, where you can use ord() to turn a boolean into an int if you want to. At least you're being explicit. -- Greg