Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.06; 'element': 0.07; '[1,': 0.09; 'cest': 0.09; 'omit': 0.09; 'slices': 0.09; 'bug': 0.12; 'doing,': 0.16; 'slice,': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'this?': 0.23; 'error': 0.23; 'deleted.': 0.24; 'skip': 0.24; 'wednesday': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'concise': 0.31; 'subject:numbers': 0.31; 'probably': 0.32; 'supposed': 0.32; 'received:google.com': 0.35; 'list': 0.37; 'clear': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'deleting': 0.60; 'ian': 0.60; 'middle': 0.60; 'negative': 0.60; 'term': 0.63; 'more': 0.64; '(5)': 0.74; 'ranges': 0.74; '2015': 0.84; 'clearer': 0.84; 'faster.': 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; bh=7nF65qM+2+Gimzjtaybq+7gv8N/SFOkOpHpF6gVEiDc=; b=FUi6dgHcmcW43V87GXJXB70vOWTN9UxIXk5u826eel/TWaqyPkMnyHCb4LEIWdmwvb srqyIkhEo21BumlHRGJ6kd5aAtFreKRkHY5qZDRdaSAWVjxQNW9qPVg3TChdeY9Y0NHr aLqc1dBTyRAm3UOXXoTzi7TINB03DjPo26hlldtuPl/0dY6L1wI6XOcQU2a9ZqdYJKN1 HuHMc/oYHKJacC6cnW7rmFV4NJpli9iQHe1CWPEcI/6nyBpa1CgJHIt/zqx+iOrpwuBe 9EitQbFjic5VgLT6IFfvtdQIjclZCqiv/OFk50R+QkAgGDJ5gu+UC79+loVXCBaAvpBL V1gQ== X-Received: by 10.107.136.89 with SMTP id k86mr1689245iod.63.1430347163763; Wed, 29 Apr 2015 15:39:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87d22mbod7.fsf@Equus.decebal.nl> References: <87lhhabxod.fsf@Equus.decebal.nl> <87d22mbod7.fsf@Equus.decebal.nl> From: Ian Kelly Date: Wed, 29 Apr 2015 16:38:43 -0600 Subject: Re: Lucky numbers in Python To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430347166 news.xs4all.nl 2850 [2001:888:2000:d::a6]:58101 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89584 On Wed, Apr 29, 2015 at 3:45 PM, Cecil Westerhof wrote: > Op Wednesday 29 Apr 2015 21:57 CEST schreef Ian Kelly: >> And although it's not clear to me what this is supposed to be doing, >> you probably no longer need the middle term if the intention is to >> continue deleting all the way to the end of the list (if it is then >> I think you have a bug in the existing implementation, since the >> last item in the list can never be deleted). > > What do you mean by this? Executing: > lucky_numbers(5) > gives: > [1, 3] > > So the last element (5) is deleted. Off by one error on my part. This is why negative skip values on ranges and slices are not recommended: they're confusing. :-) In that case you can definitely omit the middle term of the slice, which will be both more concise and clearer in intent, though probably not significantly faster.