Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63100

Re: Creating a list with holes

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!diablo1.news.osn.de!news.osn.de!diablo2.news.osn.de!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'tree': 0.05; 'list?': 0.07; 'iterate': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'rarely': 0.16; 'sorting': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'order.': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'idea,': 0.31; 'lists': 0.32; 'probably': 0.32; 'run': 0.32; 'fri,': 0.33; 'subject:with': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'that,': 0.38; 'to:addr:gmail.com': 0.65; 'worth': 0.66; 'dict.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/8SNBOqmXH3kmkSZr8hgTbTLbBuCI9yWE40hs63DoYk=; b=ek5TfnkbthZoXAErMu0C8WAH76g7da445ijONHkm1N6T649Ovg9HoHPuAxEsL8spqO K/WsS3TmRe1PU0xbIR0GOs0zaLrMB1602pLdBHDLVStG2OIoFyLPLY2lzE8ECG1acajX bfwRXaV4SO0ECIsc6kgN3IjpZvdF/VyDj5HPnr9QHa8WYUwCRRieGIXXVeZkOZ3+uMWL P6wZG63tnED8E1Z8e37Fbn/1P5HaPmZDB7cwkLUxz9x9dZTImqoWyufj3Vb2c8A16Rn1 IUgI8sIZnr1oOpSsPHcyBS7cDy632fO07MN3CINRraGIHPE9KTnh4EsvJzPqwJRn9XS/ gKWQ==
MIME-Version 1.0
X-Received by 10.180.77.49 with SMTP id p17mr4109169wiw.30.1388804301645; Fri, 03 Jan 2014 18:58:21 -0800 (PST)
In-Reply-To <CAPTjJmp+NtGYWE3S3SGjo-xoYC74Exdpci_+x4AUNgqM5=CJNQ@mail.gmail.com>
References <CACwCsY5P47-dB1NLQTUTQ=0aF6B+-M3y4hCxcUGmcVmHM8=-xQ@mail.gmail.com> <CAPTjJmp+NtGYWE3S3SGjo-xoYC74Exdpci_+x4AUNgqM5=CJNQ@mail.gmail.com>
Date Fri, 3 Jan 2014 18:58:21 -0800
Subject Re: Creating a list with holes
From Dan Stromberg <drsalists@gmail.com>
To Chris Angelico <rosuav@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4878.1388804309.18130.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388804309 news.xs4all.nl 2881 [2001:888:2000:d::a6]:35599
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63100

Show key headers only | View raw


On Fri, Jan 3, 2014 at 7:37 AM, Chris Angelico <rosuav@gmail.com> wrote:
> Depending on what exactly you need, it's probably worth just using a
> dict. In what ways do you need it to function as a list? You can
> always iterate over sorted(some_dict.keys()) if you need to run
> through them in order.

FWIW, sorting inside a loop is rarely a good idea, unless your lists
are pretty small.

For that, there are many tree datastructures available.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Creating a list with holes Dan Stromberg <drsalists@gmail.com> - 2014-01-03 18:58 -0800

csiph-web