Re: [Tutor] Naming variables

2014-01-19 Thread eryksun
On Sun, Jan 19, 2014 at 9:21 AM, spir wrote: > I guess (not sure) python optimises access of dicts used as scopes (also of > object attributes) by interning id-strings and thus beeing able to replace > them by hash values already computed once for interning, or other numeric A string object cache

Re: [Tutor] Naming variables

2014-01-19 Thread spir
On 01/19/2014 02:59 PM, Mark Lawrence wrote: On 19/01/2014 13:23, spir wrote: On 01/18/2014 07:20 PM, Pierre Dagenais wrote: Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way o

Re: [Tutor] Naming variables

2014-01-19 Thread Mark Lawrence
On 19/01/2014 13:23, spir wrote: On 01/18/2014 07:20 PM, Pierre Dagenais wrote: Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like

Re: [Tutor] Naming variables

2014-01-19 Thread spir
On 01/18/2014 07:20 PM, Pierre Dagenais wrote: Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but n

Re: [Tutor] Naming variables

2014-01-19 Thread Wiktor Matuszewski
W dniu 2014-01-18 19:20, Pierre Dagenais pisze: I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but nothing

Re: [Tutor] Naming variables

2014-01-19 Thread Wiktor Matuszewski
W dniu 2014-01-18 19:20, Pierre Dagenais pisze: I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but nothing

Re: [Tutor] Naming variables

2014-01-19 Thread Peter Otten
Pierre Dagenais wrote: > I wish to fill a list called years[] with a hundred lists called > year1900[], year1901[], year1902[], ..., year1999[]. That is too much > typing of course. Any way of doing this in a loop? I've tried stuff like > ("year" + str(1900)) = [0,0] but nothing works. > Any solut

Re: [Tutor] Naming variables

2014-01-18 Thread Danny Yoo
One thing to note: I wrote: year = [0] * 1000 Here's another way to get something equivalent: year = [] for i in range(1000): year.append(0) Here, we do an explicit loop to append those thousand zeros into the list. We'll end up with the same situation as before: year i

Re: [Tutor] Naming variables

2014-01-18 Thread Danny Yoo
If we wanted to do something with something like: year0 = 0 year1 = 0 year2 = 0 ... year999 = 0 where we keep a thousand years, and set them all to zero, then you're right in thinking that having one thousand separate variables is probably not a viable approach. We can handl

[Tutor] Naming variables

2014-01-18 Thread Pierre Dagenais
Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but nothing works. Any solution? Thank you, PierreD.