Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsfeed.straub-nv.de!feed.xsnews.nl!border-1.ams.xsnews.nl!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.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'anyway.': 0.04; 'backwards': 0.09; 'sep': 0.09; 'received:mail- wi0-f178.google.com': 0.16; 'wrote:': 0.17; 'element': 0.17; 'assumes': 0.22; 'assuming': 0.22; "i'd": 0.22; 'matching': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.25; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'subject:list': 0.28; 'fri,': 0.30; 'subject:last': 0.30; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'locations': 0.35; 'pm,': 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; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'walk': 0.71; 'upper': 0.75; 'guaranteed': 0.76; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=fccvBE4m98POtyNFAdxypDuYBv9T/PwUpnwLAPfR0VE=; b=R29NA8Sv+q5fLMQZ0w0LWyMNrWet5NQka6OlVH+iyY/9mrbaHcgTNx/Uf64eRQHwFF kCO2/z79Pbi635DZQnL/jtMWKe5/VZszIlDuXKJBwf3aMgjU4/klwqjy6qH4Emw6y8Gi hKLsd1H5/tHrYrXRQxJ8gzLbyCB8ry2adVv+23U3t+4+Fa+02enIuhlDLc2AI6cOwZFm 9dCKog+sHEwtER+RQTPsqP8FhM/o08NpuwGi+C+0kV0ubDvivf7JYAcep7TYU1UNVMwE brrMQWr8JCwHhVf5TgdSeyPCmqGY3qw7bDi1Dl3tVCqmYxEw1XZopWFhyscxBhbcbB5k fMmA== MIME-Version: 1.0 In-Reply-To: <16506499-9803-4f68-8269-f201863574c9@googlegroups.com> References: <7cd170ac-bb14-4baa-93ea-530c569d3985@googlegroups.com> <16506499-9803-4f68-8269-f201863574c9@googlegroups.com> From: Ian Kelly Date: Fri, 28 Sep 2012 21:29:53 -0600 Subject: Re: creating an artificial "last element" in sort list To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348889426 news.xs4all.nl 6866 [2001:888:2000:d::a6]:49176 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30462 On Fri, Sep 28, 2012 at 6:59 PM, Demian Brecht wro= te: >> 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= locations in the list. If it's guaranteed that they're all contiguous at t= he upper bounds, I'd just walk the list backwards until I found one that wa= sn't matching rather than filtering. The slicing operation in the second line assumes that they're all collected at the end of the list anyway.