Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!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.041 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'iterate': 0.09; 'received:209.85.214.174': 0.13; 'cc:addr:python-list': 0.15; 'mylist': 0.16; 'paulo': 0.16; 'process?': 0.16; 'thru': 0.16; 'wrote:': 0.16; 'cc:no real name:2**0': 0.21; 'subject:list': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.25; 'thanks.': 0.25; 'import': 0.27; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'list:': 0.30; 'received:209.85.214': 0.32; 'list': 0.32; "isn't": 0.32; 'it?': 0.33; 'nobody': 0.34; 'thank': 0.35; 'especially': 0.35; 'element': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'subject:from': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'huge': 0.60; '1st': 0.70; 'subject:2nd': 0.84; 'subject:huge': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=fvaElpDVrb88bHkZbXU1DIvKQmAMHaLz6lVL92wgZuk=; b=Y5/f8sJaHTG+/ReipifcL7d4C8vfzxzdwcUda5y3sAm/a8DwDF4UYnkud6iXIzEcRO WoPVdepGABnmpNsLRH72rCo8Q0eDpfGYFzzp4a/dmbn+tosVkcEooRZ0HGjHNnxa7n90 bw4ZOxQgBqyzBJJGDPn5zdWdLTMJljFFZn1zo= MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 1 Feb 2012 07:09:35 +0000 Subject: Re: Iterate from 2nd element of a huge list From: Arnaud Delobelle To: Paulo da Silva Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 1328080180 news.xs4all.nl 6866 [2001:888:2000:d::a6]:45841 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19692 On 1 February 2012 03:16, Paulo da Silva wro= te: > Em 01-02-2012 01:39, Paulo da Silva escreveu: >> Hi! >> >> What is the best way to iterate thru a huge list having the 1st element >> a different process? I.e.: >> >> process1(mylist[0]) >> for el in mylist[1:]: >> =C2=A0 =C2=A0 =C2=A0 process2(el) >> >> This way mylist is almost duplicated, isn't it? >> >> Thanks. > > > I think iter is nice for what I need. > Thank you very much to all who responded. Nobody mentioned itertools.islice, which can be handy, especially if you weren't interested in the first element of the list: from itertools import islice: for el in islice(mylist, 1): process2(el) --=20 Arnaud