Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'syntax': 0.04; '(python': 0.07; 'subject:create': 0.09; 'python': 0.11; '2.6.4': 0.16; '[])': 0.16; 'goebel': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'posting': 0.31; '2009,': 0.31; 'subject:lists': 0.35; 'received:google.com': 0.35; '2.6': 0.36; 'clear': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'help,': 0.39; 'to:addr:python.org': 0.39; 'subject:Fwd': 0.61; 'here:': 0.62; 'thomas': 0.65; 'stated': 0.69; '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=lI0V0nM2yEGm0KoQ+w0RIjidEHrjaGohJGpZbPk0Rro=; b=Iuu9uSMYSFXGBGa39e2HR/nilSZdz5VEApWwxfiZJOEcj8YcTpq/0IY0gD+6Rnh74K oYJ+jIMhKt5WaCTf27AJw4hR1kkKGsvtgd5spiR7+4c13lzGjDv1fWHjRnVdYANM54C+ oXQeB48iKOySRnJhWQrqfnpfIIRT20li2hdf2IF2qF9B2Qsdnz5vcmZBQVdEnd+yQpgR b+Ro4jeQoNve/TrYlHp5w1MjmVZ+yvUmQZo2tITAt4Sve51askYQPpzvvI46wBcLUC5g ThvO09wh7FNuNDHOMmdMI2NCiDNVRzyCqV8uDyFhE9DHLXXnVLtbLhYqvXCr4ksg8ia4 CKUQ== MIME-Version: 1.0 X-Received: by 10.60.93.105 with SMTP id ct9mr2351044oeb.70.1365690822011; Thu, 11 Apr 2013 07:33:42 -0700 (PDT) In-Reply-To: <5166BDED.7090002@th-nuernberg.de> References: <4c47da9e-c632-4855-98a7-0506d8013046@googlegroups.com> <51656F6A.5040103@th-nuernberg.de> <5166A297.70104@th-nuernberg.de> <5166BDED.7090002@th-nuernberg.de> Date: Thu, 11 Apr 2013 16:33:41 +0200 Subject: Re: Fwd: use a loop to create lists From: Franz Kelnreiter To: python-list@python.org Content-Type: multipart/alternative; boundary=047d7b33d5a051b2eb04da16ac5c 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: 63 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365690830 news.xs4all.nl 2663 [2001:888:2000:d::a6]:44105 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43375 --047d7b33d5a051b2eb04da16ac5c Content-Type: text/plain; charset=ISO-8859-1 On Thu, Apr 11, 2013 at 3:43 PM, Thomas Goebel < Thomas.Goebel@ohm-hochschule.de> wrote: > ... > > I get a syntax error, as I exepected (Python 2.6.4 (r264:75708, Oct 26 > > 2009, 08:23:19)). > > Sorry Franz, > > as you are using python 2.6 you have to use > > d1 = dict(('list_' + str(i), []) for i in range(3)) > d2 = dict(('list_' + str(i), [m for m in range(3)]) for i in range(3)) > > like stated here: > > http://stackoverflow.com/questions/1747817/python-create-a-dictionary-with-list-comprehension > -- > Thank you, Thomas, for your last posting and your help, that makes everything clear for me now! All best, Franz --047d7b33d5a051b2eb04da16ac5c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Thu, Apr 11, 2013 at 3:43 PM, Thomas Goebel <Thomas.Goebel@ohm-hochschule.de> wrote:
...
> I get a syntax error, as I exepected (Python 2.6.4 (r264:75708, Oct 26=
> 2009, 08:23:19)).

Sorry Franz,

as you are using python 2.6 you have to use

d1 =3D dict(('list_' + str(i), []) for i in range(3))
d2 =3D dict(('list_' + str(i), [m for m in range(3)]) for i in rang= e(3))

like stated here:
http://stackoverflow.com/q= uestions/1747817/python-create-a-dictionary-with-list-comprehension
--

Thank you, Thomas, for your last posti= ng and your help, that makes everything clear for me now!=A0

All best, Franz

--047d7b33d5a051b2eb04da16ac5c--