Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.glorb.com!news2.glorb.com!news.astraweb.com!border6.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Equivalent code to the bool() built-in function References: <4da9fb0b$0$13696$426a74cc@news.free.fr> <87k4etho6e.fsf@benfinney.id.au> <4daa2b72$0$32037$426a74cc@news.free.fr> X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Sun, 17 Apr 2011 12:39:54 +1000 Message-ID: <87d3klha85.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:EidZ1AefpqqDJUC3zYx0P/Imvnk= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 48 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: c34d581f.news.astraweb.com X-Trace: DXC=jQiIT6jFG8d^5mDXS]l4MgL?0kYOcDh@jN7:H2`MmAUc\g^KX1`]9Cm]G;2>V^?kWcbEW9A[5UK?eNZ[SL`C\KgcU\gEnkKoDkf Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3366 candide writes: > Le 16/04/2011 23:13, Ben Finney a écrit : > > > The ‘bool’ built-in is not a function. > > Oops, unfortunate confusion!! but built-in types and built-in > functions are sometimes so similar from the user's point of view ;) Yes, intentionally so, because: > All the same, you can notice that the official documentation describes > bool() as a built-in function, cf. > http://docs.python.org/library/functions.html sometimes functions are replaced by types, or vice versa, and the user code doesn't have to know. Sadly, the result can be that the documentation is sometimes out of date with the implementation :-) candide writes: > Le 16/04/2011 23:38, Ben Finney a écrit : > > > So the answer to the OP's question is no: the function isn't > > equivalent to the type, > > Can bool() type and [my example] bool_equivalent() function return > different values ? Why do you need to know? (I should have asked that question earlier.) > > because the OP's ‘bool_equivalent’ function necessarily uses the > > built-in ‘bool’ type, while the reverse is not true. > > The documentation doesn't seem to state it performs this call. Right, just as APIs that return strings won't explicitly talk about calling the ‘str’ type constructor. I don't understand why you expect that. -- \ “My business is to teach my aspirations to conform themselves | `\ to fact, not to try and make facts harmonise with my | _o__) aspirations.“ —Thomas Henry Huxley, 1860-09-23 | Ben Finney