Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'constructor': 0.07; 'function,': 0.07; 'python': 0.07; 'bool': 0.09; 'false,': 0.09; 'type;': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'boolean': 0.16; 'namespace.': 0.16; 'op.': 0.16; 'pointers': 0.16; 'readable': 0.16; 'subject:() ': 0.16; 'subject:function': 0.16; 'sure,': 0.16; 'call.': 0.19; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'mon,': 0.22; 'example.': 0.23; 'subject:code': 0.23; 'objects': 0.24; "didn't": 0.25; 'calling': 0.25; 'function': 0.27; 'message- id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'daniel': 0.29; 'explicitly': 0.29; '>the': 0.31; 'to:addr:python-list': 0.32; 'agree': 0.32; 'expression': 0.33; 'words,': 0.33; 'change': 0.34; 'there': 0.35; 'explicit': 0.35; 'rather': 0.36; 'assigned': 0.37; 'received:209.85': 0.37; 'exactly': 0.37; 'apr': 0.38; 'hack': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'allows': 0.40; 'best': 0.60; 'direct': 0.61; 'charset:windows-1252': 0.61; '2011': 0.62; 'show': 0.67; '12:46': 0.84; 'casting': 0.84; 'received:209.85.210.174': 0.84; 'received:mail-iy0-f174.google.com': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=6k5EgIbFEIgznGNoHOmolo4bys54EphKnIhygm0/MsE=; b=KCdBtPdsSecoCwlDUiEmNjlsvevv5OlduwTP+92dd2z+CPTMYwPR7U7a9fGETEepDL UQDzpGkJvNDtmsk+5bTpcI/anYHt/HK1w+P/vyplFmtn3E0EYV4eY8xPbExyYXseE9MR XzOYaFxcAyAjNIWgDdYH+LKrmC/nzdzevpyZ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Ga54XVw29ZJeBNA+gr64GhTifuv6LiGgbHtNZ+cXcDiGftQ6ULLVyFl2WsZZtXFNkB O8PYudJHF/7OvwrfcWrsBE86aDF04Rw878HlgUs9P3hkliTQVN8AV2gRbJsnB0eg2VGM mT3uCL8woIvByE4DkXkNBdUMvWNxmFjOgOymY= MIME-Version: 1.0 In-Reply-To: <4DAB97FD.20103@ieee.org> References: <4da9fb0b$0$13696$426a74cc@news.free.fr> <87k4etho6e.fsf@benfinney.id.au> <4DAB97FD.20103@ieee.org> Date: Mon, 18 Apr 2011 14:16:38 +1100 Subject: Re: Re: Equivalent code to the bool() built-in function From: Daniel Kluev To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303096602 news.xs4all.nl 81484 [::ffff:82.94.164.166]:51229 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3452 On Mon, Apr 18, 2011 at 12:46 PM, Dave Angel wrote: > He didn't say that the function will call the bool() type (constructor), = but > that it will use the bool type; Actually, he did say exactly that > Any boolean expression is going to be _calling the built-in =91bool=92 ty= pe constructor_ (underscores are mine) >The one that may not is the function bool(). Its not function, its type. There is no wrapper, bool(x) is direct constructor call. > Once bool has been reassigned, calling it may not return True or False an= y more. Not sure what did you want to show with this example. You just assigned name in locals() namespace. Boolean type itself didn't change because of that and would still call PyObject_IsTrue() and return according constant. Sure, python allows to change namespaces in very flexible way, but we are talking about specific objects (PyBool_Type) rather than pointers to them. > in other words, it will return True or False. Well, his code explicitly returns True or False, so this was not doubted. Although I agree with Ben that this doesn't have any practical meaning. bool() is more readable and implementation-independent way to do explicit casting to boolean than the hack in OP. --=20 With best regards, Daniel Kluev