Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'function,': 0.07; 'repository': 0.07; 'type,': 0.07; 'python': 0.07; 'builtin': 0.09; 'sun,': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'repr': 0.16; 'subject:() ': 0.16; 'subject:function': 0.16; 'header:In-Reply- To:1': 0.22; 'subject:code': 0.23; 'pointed': 0.25; '(in': 0.27; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'daniel': 0.29; '17,': 0.31; 'comparison': 0.31; 'to:addr:python-list': 0.32; 'skip:& 10': 0.34; 'skip:o 20': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'best': 0.60; 'you.': 0.61; '2011': 0.62; 'imagine': 0.72; 'candide': 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; bh=obNMRlbDeyESuwT8+s3+vllD9yvwAI8mLwJ5q0dWK54=; b=BeHCBpIiBLG9OQFl8OY675VLNJgF5RRRyOnQ5yfmiUrLo/BfDbut+LIsmAdeigvAvo VtT8s4mPcyaaErwMv0v+DhAjiWNwm2cc3w2RDZdMKdcJ2I0Rn0YJ65vKLhecTNegAze9 ey67DtAJIliyj1Zf56WizkZp+mj5l9genjt/o= 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; b=txlQtO3LDsIPY2nzMcdB8cILSsjPjM3KYPTao9ST1I3pZh9If1KbNJdIim4wuyvmq0 P6PBxezalfViX+TH+JiML6uWovDV8WOcCI9ZMnem9ODt0RVIyaZMSTuosZHmxpW5cMcd R1SzBijWA0CLNfzzW+FhCtC8Cveof13el35fY= MIME-Version: 1.0 In-Reply-To: <4daaa6f6$0$20187$426a74cc@news.free.fr> 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> Date: Sun, 17 Apr 2011 21:11:55 +1100 Subject: Re: Equivalent code to the bool() built-in function From: Daniel Kluev To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 15 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303035118 news.xs4all.nl 81478 [::ffff:82.94.164.166]:57528 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3388 On Sun, Apr 17, 2011 at 7:38 PM, candide wrote: > I could't imagine a builtin function having a so trivial implementation. As it was pointed out, its not function, its type, SETBUILTIN("bool", &PyBool_Type); While its __new__ is indeed trivial (in essence, it just calls PyObject_IsTrue), it also provides needed comparison ops, repr and other magic methods for the type. You can check Objects/boolobject.c in python repository if its implementation is interesting for you. -- With best regards, Daniel Kluev