Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'correct.': 0.07; 'preferable': 0.09; 'sequences.': 0.09; 'anyway': 0.14; '24,': 0.16; 'garbage': 0.16; 'incorrect': 0.16; 'iterable': 0.16; 'iterables': 0.16; 'iterator': 0.16; 'iterator,': 0.16; 'notation': 0.16; 'succinct': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'email addr:gmail.com>': 0.22; '>': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'raise': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'subject:learning': 0.31; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'opposed': 0.36; 'returning': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'results.': 0.60; 'more': 0.64; 'hand': 0.80; 'silently': 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=te0NO8EnG1VtuPuhxC0sE5+d5QGw/pSQOEB58Wh4R/g=; b=dA/m6xY6hZUao8h+mVuS2o4eyAW6B36zA1edP7CeDkwKTqiwGderRUzBlG71v5Blhj N+bT170ZvdOa63Qa8RthyGjsj0Cvc3opjP6q4Oflq53r8R43L6cxUhYHXsjiGkHStkwA 5LkBGHnaa8teWrrQcv1UgoERXGVZvpG8X/snAnSBKNKeoMnWHByeHPsfUZqbdFsMi/SB Vba2Qb/ekOJvKj3Gia+ggGQWOlohf8rGYkFhT8cczDU/AMLOY2lmgH728ZcDuuIgXjC6 gyT2h9J1UJgAXZi+o6mr+g/chVsmaDtwr8xyqCUcziz0dcWk0MecRn0hY6HnNgmpRzXm fJPA== X-Received: by 10.68.241.130 with SMTP id wi2mr58260628pbc.89.1419485829208; Wed, 24 Dec 2014 21:37:09 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <8a840698-a3be-4889-9ddd-756a553e6f48@googlegroups.com> References: <878uhyb3hq.fsf@net82.ceos.umanitoba.ca> <8a840698-a3be-4889-9ddd-756a553e6f48@googlegroups.com> From: Ian Kelly Date: Wed, 24 Dec 2014 22:36:28 -0700 Subject: Re: learning to use iterators To: Python Content-Type: multipart/alternative; boundary=047d7b339d0d9d235b050b03cc31 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419485832 news.xs4all.nl 2914 [2001:888:2000:d::a6]:56452 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82910 --047d7b339d0d9d235b050b03cc31 Content-Type: text/plain; charset=UTF-8 On Wed, Dec 24, 2014 at 1:34 PM, Rustom Mody wrote: > +1 for the slice in succinct form Not only more succinct but also more correct. The purpose of islice is to slice arbitrary iterables as opposed to just sequences. But this function requires a reentrant iterable anyway and returns garbage if you pass it an iterator, so there's really no reason for it here. The version using slice notation on the other hand will raise a TypeError if you pass it an iterator or anything else that can't be sliced, which is preferable to silently returning incorrect results. --047d7b339d0d9d235b050b03cc31 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable --047d7b339d0d9d235b050b03cc31--