Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!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.050 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'backwards': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'element': 0.17; 'assuming': 0.22; "i'd": 0.22; 'matching': 0.23; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'cc:addr:gmail.com': 0.27; 'subject:list': 0.28; 'subject:last': 0.30; 'received:google.com': 0.34; 'list': 0.35; 'locations': 0.35; 'received:209.85': 0.35; 'list.': 0.35; 'subject:" ': 0.36; "wasn't": 0.36; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'walk': 0.71; 'upper': 0.75; 'guaranteed': 0.76 Newsgroups: comp.lang.python Date: Fri, 28 Sep 2012 17:59:48 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=74.198.150.36; posting-account=US_9zQoAAABOtpKbrs9cDfYpbT6eMPnL References: <7cd170ac-bb14-4baa-93ea-530c569d3985@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 74.198.150.36 MIME-Version: 1.0 Subject: Re: creating an artificial "last element" in sort list From: Demian Brecht To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: dave , Python 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: , Message-ID: Lines: 6 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348880397 news.xs4all.nl 6860 [2001:888:2000:d::a6]:45938 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30445 > f =3D filter(lambda s: s =3D=3D a[-1], a) That line's assuming that the last element may also be found in arbitrary l= ocations in the list. If it's guaranteed that they're all contiguous at the= upper bounds, I'd just walk the list backwards until I found one that wasn= 't matching rather than filtering.