Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.03; 'python': 0.09; "'test": 0.09; '[])': 0.09; 'dict': 0.09; 'supported.': 0.09; 'subject:Help': 0.10; '"test': 0.16; '1",': 0.16; '2",': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'skip:` 20': 0.17; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '2.6': 0.27; 'subject:lists': 0.32; 'to:addr:python-list': 0.33; 'nov': 0.35; 'there': 0.35; '12,': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'content-disposition:inline': 0.60; 'received:10.94': 0.84; 'received:89': 0.86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uni-mainz.de; i=@uni-mainz.de; q=dns/txt; s=ironport; t=1352814914; x=1384350914; h=date:from:to:subject:message-id:references:mime-version: in-reply-to; bh=cByQMC5ztai+FrhXPKr0TrAbPsUZXI4sCWEiEB1oVJM=; b=TBcRYNUfFJXNLQMb/W6L+lsgRHJ0EWOyOQsTWq4TZJjyhtTDio58t9K6 LMNweHMOrpY5RV+8O8wayZ1OlkPpL8d/UKpBzjMcR9pbIhLRBlai/Tj0q JjUHRVztnt5PH8O9XQ7XcZqNRNmnEDo1m58KN1V19ayVEuxUEhGzVh7Bd M=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApwEABpQolAKXgZY/2dsb2JhbABExH6CHgEBBTpPCxgeEBQpIIghqV2QMIwhgy2CRmEDlXsBkEOCcIIY Date: Tue, 13 Nov 2012 14:53:55 +0100 From: Thomas Bach To: Subject: Re: Help building a dictionary of lists References: <9f44d1de-bccf-41ad-8529-ff8a65d7e2b4@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [89.204.138.134] 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352814915 news.xs4all.nl 6943 [2001:888:2000:d::a6]:35685 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33240 On Mon, Nov 12, 2012 at 11:41:59PM +0000, Joshua Landau wrote: > > Dict comprehension: > {i:[] for i in ["Test 1", "Test 2", "Test 3"]} In Python 2.6 this syntax is not supported. You can achieve the same there via dict((i, []) for i in ['Test 1', 'Test 2', 'Test 3']) Also have a look at ``collections.defaultdict``. Regards, Thomas.