Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!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.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'example:': 0.03; 'friday,': 0.09; 'jan': 0.12; 'random': 0.14; '[10]': 0.16; 'defaultdict': 0.16; 'different,': 0.16; 'none.': 0.16; 'wrote:': 0.18; 'example': 0.22; 'to:name:python-list@python.org': 0.22; 'creating': 0.23; 'help!': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'allows': 0.31; 'lists': 0.32; 'another': 0.32; 'beginning': 0.33; 'fri,': 0.33; "i'd": 0.34; 'subject:with': 0.35; 'something': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'in.': 0.36; 'january': 0.37; 'list': 0.37; 'e.g.': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'above,': 0.60; 'tell': 0.60; 'email addr:gmail.com': 0.63; 'between': 0.67; 'end.': 0.84; 'holes': 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 :content-type; bh=oy99DBGyKHnkkVpUXu7duVotWR4QCGhYAN6x5A60UN4=; b=nzcs2ZhtKgGqgFYvLIzsmAPEmp5Aio8lysY88hyILyyOcbyNKwwpGnJKYVwEGDAQ7T th/g53esnLbb3Y8waepOHlRjpRFh36fRAsnX33GEbFdMkh2EBFhFl6XblcMZRza3Ksp/ GmON/w1wkb9qlm8dwiFfudjA9VSrkpXLhTdkzaYZspkkP562d30kdbRbkr7/UNYWZG79 2DtKioHtBYMXjd97V0CdXP8CAIZ1pK0yqvgkQFCEkx5ttWWInmLk4ZKHKzeLJCbzt0IP 3iF9ZGE9f4O5txJMMmQkXJvWPyIG5jWQgDSiABqbUizsn5wpEBPq+vHYXEMT1krG8wRU nIig== MIME-Version: 1.0 X-Received: by 10.194.123.8 with SMTP id lw8mr61137636wjb.40.1388763681638; Fri, 03 Jan 2014 07:41:21 -0800 (PST) In-Reply-To: References: Date: Fri, 3 Jan 2014 10:41:21 -0500 Subject: Re: Creating a list with holes From: Larry Martell To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388763689 news.xs4all.nl 2942 [2001:888:2000:d::a6]:34431 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63064 On Fri, Jan 3, 2014 at 10:30 AM, wrote: > On Friday, January 3, 2014 4:19:09 PM UTC+1, Larry....@gmail.com wrote: >> I think I know the answer is no, but is there any package that allows >> >> creating a list with holes in it? E.g. I'd want to do something like: >> >> x[10] = 12 >> x[20] = 30 >> >> I'm thinking of something like defaultdict but for lists (I know >> >> that's very different, but ... ) > > Hello Larry! > > The thing is, where to put the holes? A costum function can be made if you want the hole to be placed for example: > 1. In random > 2. Every nth hole(Or with another sequence) > 3. In the beginning or end. > > Please tell me how do you want them, and I will try my best to help! The holes would be between the items I put in. In my example above, if I assigned to [10] and [20], then the other items ([0..9] and [11..19]) would have None.