Path: csiph.com!usenet.pasdenom.info!gegeweb.org!noc.nerim.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'argument': 0.04; 'binary': 0.05; 'subject:code': 0.07; 'python': 0.09; 'happens.': 0.09; 'parsed': 0.09; 'undocumented': 0.09; 'call?': 0.16; 'chained': 0.16; 'comparison:': 0.16; 'operators.': 0.16; 'received:192.168.1.50': 0.16; 'ternary': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'equivalent': 0.20; '(by': 0.22; 'are.': 0.22; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'compiled': 0.27; 'regular': 0.27; 'context,': 0.29; "d'aprano": 0.29; 'steven': 0.29; "i'm": 0.29; 'code': 0.31; '+0200,': 0.33; 'docs': 0.33; 'to:addr:python-list': 0.33; 'operations': 0.33; 'generic': 0.35; 'something': 0.35; 'explain': 0.36; 'method': 0.36; 'does': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'think': 0.40; 'your': 0.60; 'received:62': 0.62; 'thomas': 0.62; 'necessarily': 0.63; 'jul': 0.65; 'talking': 0.66; 'special': 0.73; 'from:addr:t': 0.84; 'received:62.75': 0.84; 'secret,': 0.84 Date: Mon, 02 Jul 2012 16:26:02 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: code review References: <6c39594f-79cb-4d4f-967e-bbc3f68cdbdf@f8g2000pbf.googlegroups.com> <4fed59b7$0$29978$c3e8da3$5496439d@news.astraweb.com> <2662370.TGmo96CKe1@PointedEars.de> <87wr2oecf6.fsf@dpt-info.u-strasbg.fr> <4FEF7117.7000109@jollybox.de> <4fefb0ad$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ff0eebf$0$29988$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <4ff0eebf$0$29988$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341239173 news.xs4all.nl 6874 [2001:888:2000:d::a6]:36317 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24771 On 07/02/2012 02:43 AM, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 09:35:40 +0200, Thomas Jollans wrote: >> This is simply wrong. The comparisons are not acting as binary >> operators. > > Of course they are. Take this chained comparison: Technically, yes - two-input operations are happening. Syntactically, no. Read my post. > 1) What is the operator in this expression? Is it < or == or something > else? I think I've answered this - it's the combination. > 2) What double-underscore special method does it call? Where is this > mysterious, secret, undocumented method implemented? > > 3) Why do the Python docs lie that a < b == c is exactly equivalent to > the short-circuit expression (a < b) and (b == c) with b evaluated once? > > 4) And how do you explain that the compiled byte code actually calls the > regular two-argument binary operators instead of your imaginary three- > argument ternary operator? In this context, I don't care what actually happens. I'm talking about how the code can be parsed (by the generic reader, not necessarily the python interpreter).