Re: Nested dictionaries trouble

2007-04-21 Thread Bruno Desthuilliers
IamIan a écrit : > I am using the suggested approach to make a years list: > > years = ["199%s" % x for x in range(0,10)] > years += ["200%s" % x for x in range(0,10)] > > I haven't had any luck doing this in one line though. Is it possible? # Q, D and pretty obvious years = ["199%s" % x for x i

Re: Nested dictionaries trouble

2007-04-21 Thread rzed
IamIan <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Thank you again for the great suggestions. I have one final > question about creating a httpMonths dictionary like {'Jan':'01' > , 'Feb':'02' , etc} with a minimal amount of typing. My code > follows (using Python 2.3.4): > > import c

Re: Nested dictionaries trouble

2007-04-19 Thread IamIan
Thank you again for the great suggestions. I have one final question about creating a httpMonths dictionary like {'Jan':'01' , 'Feb':'02' , etc} with a minimal amount of typing. My code follows (using Python 2.3.4): import calendar # Create years list, formatting as strings years = map(str, xrang

Re: Nested dictionaries trouble

2007-04-18 Thread Steven D'Aprano
On Wed, 18 Apr 2007 12:16:12 -0700, IamIan wrote: > I am using the suggested approach to make a years list: > > years = ["199%s" % x for x in range(0,10)] > years += ["200%s" % x for x in range(0,10)] > > I haven't had any luck doing this in one line though. Is it possible? years = ["199%s" % x

Re: Nested dictionaries trouble

2007-04-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, IamIan wrote: > years = ["199%s" % x for x in range(0,10)] > years += ["200%s" % x for x in range(0,10)] > > I haven't had any luck doing this in one line though. Is it possible? In [48]: years = map(str, xrange(1999, 2011)) In [49]: years Out[49]: ['1999', '2000', '20

Re: Nested dictionaries trouble

2007-04-18 Thread Steven W. Orr
On Wednesday, Apr 18th 2007 at 12:16 -0700, quoth IamIan: =>I am using the suggested approach to make a years list: => =>years = ["199%s" % x for x in range(0,10)] =>years += ["200%s" % x for x in range(0,10)] => =>I haven't had any luck doing this in one line though. Is it possible? I'm so green

Re: Nested dictionaries trouble

2007-04-18 Thread IamIan
I am using the suggested approach to make a years list: years = ["199%s" % x for x in range(0,10)] years += ["200%s" % x for x in range(0,10)] I haven't had any luck doing this in one line though. Is it possible? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
On Apr 11, 7:28 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 11, 7:01 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > > On Apr 11, 2:57 pm, Bruno Desthuilliers > > > <[EMAIL PROTECTED]> wrote: > > > IamIan a écrit : > > > > yearTotals = dict([(year, dict.fromkeys(months, 0)) for year in years]) > > >

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
On Apr 11, 7:01 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 11, 2:57 pm, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > > IamIan a écrit : > > > yearTotals = dict([(year, dict.fromkeys(months, 0)) for year in years]) > > > HTH > > List comprehensions without a list? What? Where? How? Oo

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
On Apr 11, 2:57 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > IamIan a écrit : > > yearTotals = dict([(year, dict.fromkeys(months, 0)) for year in years]) > > HTH List comprehensions without a list? What? Where? How? -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-11 Thread IamIan
Thank you everyone for the helpful replies. Some of the solutions were new to me, but the script now runs successfully. I'm still learning to ride the snake but I love this language! Ian -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
IamIan wrote: > Hello, > > I'm writing a simple FTP log parser that sums file sizes as it runs. I > have a yearTotals dictionary with year keys and the monthTotals > dictionary as its values. The monthTotals dictionary has month keys > and file size values. The script works except the results are

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
1) You have this setup: logMonths = {"Jan":"01", "Feb":"02",...} yearTotals = { "2005":{"01":0, "02":0, } "2006": "2007": } Then when you get a value such as "Jan", you look up the "Jan" in the logMonths dictionary to get "01". Then you use "01" and the ye

Re: Nested dictionaries trouble

2007-04-11 Thread Bruno Desthuilliers
IamIan a écrit : > Hello, > > I'm writing a simple FTP log parser that sums file sizes as it runs. I > have a yearTotals dictionary with year keys and the monthTotals > dictionary as its values. The monthTotals dictionary has month keys > and file size values. The script works except the results a

Re: Nested dictionaries trouble

2007-04-11 Thread Terry Reedy
"IamIan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hello, | | I'm writing a simple FTP log parser that sums file sizes as it runs. I | have a yearTotals dictionary with year keys and the monthTotals | dictionary as its values. The monthTotals dictionary has month keys | and fi

Re: Nested dictionaries trouble

2007-04-11 Thread Gabriel Genellina
En Wed, 11 Apr 2007 15:57:56 -0300, IamIan <[EMAIL PROTECTED]> escribió: > I'm writing a simple FTP log parser that sums file sizes as it runs. I > have a yearTotals dictionary with year keys and the monthTotals > dictionary as its values. The monthTotals dictionary has month keys > and file size