Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'expressions': 0.07; 'subject:code': 0.07; 'alain': 0.09; 'correct,': 0.09; 'defined,': 0.09; 'reference:': 0.09; 'restriction': 0.09; 'def': 0.10; 'language': 0.14; '...,': 0.16; 'expressions)': 0.16; 'op1': 0.16; 'op2': 0.16; 'operators,': 0.16; 'opn': 0.16; 'received:192.168.1.50': 0.16; 'syntactic': 0.16; 'wrote:': 0.17; 'certainly': 0.17; "shouldn't": 0.17; '(or': 0.18; 'equivalent': 0.20; 'bit': 0.21; 'supposed': 0.21; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'raw': 0.27; '"in': 0.29; 'comparison': 0.29; 'consult': 0.29; 'writes:': 0.29; "we're": 0.30; 'evaluation': 0.30; 'right?': 0.33; 'to:addr:python-list': 0.33; 'done': 0.34; 'pm,': 0.35; 'there': 0.35; 'except': 0.36; 'but': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'most': 0.61; 'face': 0.61; 'first': 0.61; 'received:62': 0.62; 'thomas': 0.62; 'more': 0.63; '(single': 0.84; 'from:addr:t': 0.84; 'received:62.75': 0.84; 'technically': 0.91; 'refuse': 0.93 Date: Sat, 30 Jun 2012 23:35:19 +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> In-Reply-To: <87wr2oecf6.fsf@dpt-info.u-strasbg.fr> 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341092123 news.xs4all.nl 6972 [2001:888:2000:d::a6]:46541 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24704 On 06/30/2012 11:07 PM, Alain Ketterlin wrote: > Thomas Jollans writes: > >>>>>> def is_valid_password(password): >>>>>> return mud.minpass <= len(password) <= mud.maxpass > >> Which of the two comparisons is done first anyway? >> "In the face of ambiguity, refuse the temptation to guess." > > There is no ambiguity. See the language reference: Of course it's technically clearly defined, but the syntax isn't explicit. To know what the order is (or whether there is an order!) one has to consult the language reference (which shouldn't be necessary), or make an educated guess, which would almost certainly be correct, but we're supposed to refuse the temptation to guess, right? > "Formally, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN > are comparison operators, then a op1 b op2 c ... y opN z is equivalent > to a op1 b and b op2 c and ... y opN z, except that each expression is > evaluated at most once." > > The last restriction (single evaluation of involved expressions) makes > this a bit more than raw syntactic sugar.