Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'clause': 0.09; 'false,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'second.': 0.09; 'wrote': 0.14; 'colon.': 0.16; 'computes': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:bit': 0.16; 'sure.': 0.16; 'wrote:': 0.18; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'but': 0.35; 'there': 0.35; 'doing': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'further': 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'therefore': 0.72; 'obvious': 0.74 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: A curious bit of code... Date: Fri, 14 Feb 2014 07:19:32 -0500 (EST) Organization: news.gmane.org References: <4cc09129-43ee-4205-a24c-03f92b594abc@googlegroups.com> X-Gmane-NNTP-Posting-Host: dpc6744195087.direcpc.com X-Newsreader: PiaoHong Usenet NewsReaders 1.36 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392380171 news.xs4all.nl 2851 [2001:888:2000:d::a6]:51688 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66293 Terry Reedy Wrote in message: > On 2/13/2014 1:37 PM, forman.simon@gmail.com wrote: >> I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. >> >> if key[:1] + key[-1:] == '<>': ... > > if key[:1] == '<' and key[-1:] == '>: ... > is the obvious choice to me. If the first clause is false, it never > computes the second. > And therefore no need for the second colon. if key[:1] == '<' and key[-1] == '>: ... -- DaveA