Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!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.061 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.01; '[0,': 0.09; 'subject:create': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'goebel': 0.16; 'simplified': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'received:209.85': 0.35; 'subject:lists': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'thomas': 0.65; 'as:': 0.81; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Kqko+TPCb/G3za5TBv1V3x7COs+nE5pmUFJpyHmJ8nE=; b=KqubfuafzGBI5BPkOgxm9/yXEOZSaAZVGSy3/OxNUeWlq32nikO7Nf9g0sHuV8/R+T 8iGT4iJiiFDMiqHdeAfkS6UfTkLLX1IP8pmRS5BHsSo0Ov/rdj/aCWCBj2Y4oR56N/YC kGZQv+Bp+jFOripXdn18y7Yrj1aQosP3NFN0lHzfJrr3z5ru4E1acznrOteHXcoiiu2x jjATad8aT3h38pOGFgVaEd8+f5rPWlzGeQ88UNEwlTDwIxlznbK/S3FMrSHAjOyesoRL rUhDo+ur1y7O8IGt8/VmcNH2H1/mFpHbXoaPvY/ryV4DpsfgCJEMonPLaQdx97UeAjdr PXOg== MIME-Version: 1.0 X-Received: by 10.220.109.145 with SMTP id j17mr4936522vcp.34.1365686561611; Thu, 11 Apr 2013 06:22:41 -0700 (PDT) In-Reply-To: <5166B345.8080200@th-nuernberg.de> References: <4c47da9e-c632-4855-98a7-0506d8013046@googlegroups.com> <51656F6A.5040103@th-nuernberg.de> <5166A297.70104@th-nuernberg.de> <5166B345.8080200@th-nuernberg.de> Date: Thu, 11 Apr 2013 23:22:41 +1000 Subject: Re: use a loop to create lists From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365686564 news.xs4all.nl 2667 [2001:888:2000:d::a6]:47380 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43366 On Thu, Apr 11, 2013 at 10:57 PM, Thomas Goebel wrote: > [a for a in range(3)] > > will return a list > [0, 1, 2] Simplification possible: That's the same as: list(range(3)) > f = {'list_' + str(n):[m for m in range(3)] for n in range(3)} Meaning that this can be simplified too: f = {'list_' + str(n):list(range(3)) for n in range(3)} ChrisA