On Thu, Apr 11, 2013 at 3:43 PM, Thomas Goebel <
thomas.goe...@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
* On 11/04/2013 16:11, Franz Kelnreiter wrote:
> On Thu, Apr 11, 2013 at 2:57 PM, Thomas Goebel <
> thomas.goe...@ohm-hochschule.de> wrote:
>
>> ...
>> Which is the same as:
>> f = {'list_' + str(n):[m for m in range(3)] for n in range(3)}
>>
> [...]
> But didnt you miss square brackets:
>
> f =
On Thu, Apr 11, 2013 at 2:57 PM, Thomas Goebel <
thomas.goe...@ohm-hochschule.de> wrote:
> ...
> Which is the same as:
> f = {'list_' + str(n):[m for m in range(3)] for n in range(3)}
>
Thomas, thank you for your patience and your long explanation! Now I
understand better this shorthand expressio
* On 11/04/2013 14:11, Franz Kelnreiter wrote:
> On Thu, Apr 11, 2013 at 1:46 PM, Thomas Goebel wrote:
>
>> global_list = {'_'.join(['list', str(i)]):[] for i in range(20)}
>
> Thanks for your explanation, I think I know what you want to do and I would
> very much like to understand your code in d
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_'
* On 11/04/2013 14:11, Franz Kelnreiter wrote:
> On Thu, Apr 11, 2013 at 1:46 PM, Thomas Goebel wrote:
>>
>> the difference between your and my code is that
>>
>> global_list = {'_'.join(['list', str(i)]):[] for i in range(20)}
>>
>> creates a dict 'global_list' which has 20 keys named from 'list_0
-- Forwarded message --
From: Franz Kelnreiter
Date: Thu, Apr 11, 2013 at 2:09 PM
Subject: Re: use a loop to create lists
To: thomas.goe...@ohm-hochschule.de
On Thu, Apr 11, 2013 at 1:46 PM, Thomas Goebel <
thomas.goe...@ohm-hochschule.de> wrote:
> * On 11/04/2013 13:
* On 10/04/2013 10:40, martaamu...@gmail.com wrote:
> Hi!
>
> I would like to create a list containing lists. I need each list to
> have a differente name and i would like to use a loop to name the
> list.
> [...]
> global_list=[]
> for i in range (20):
> ("list_"+i)=[] #These would be the n
On Apr 10, 1:40 pm, martaamu...@gmail.com wrote:
> Hi!
>
> I would like to create a list containing lists. I need each list to have a
> differente name and i would like to use a loop to name the list. But as the
> name, is a string, i cannot asign it to a value... how can I do that??
>
> global_l
On 04/10/2013 04:40 AM, martaamu...@gmail.com wrote:
Hi!
I would like to create a list containing lists. I need each list to have a
differente name and i would like to use a loop to name the list. But as the
name, is a string, i cannot asign it to a value... how can I do that??
global_list=[
On Wed, Apr 10, 2013 at 6:40 PM, wrote:
> Hi!
>
> I would like to create a list containing lists. I need each list to have a
> differente name and i would like to use a loop to name the list. But as the
> name, is a string, i cannot asign it to a value... how can I do that??
>
>
> global_list=[
Hi!
I would like to create a list containing lists. I need each list to have a
differente name and i would like to use a loop to name the list. But as the
name, is a string, i cannot asign it to a value... how can I do that??
global_list=[]
for i in range (20):
("list_"+i)=[] #These would
12 matches
Mail list logo