On Sat, 09 Sep 2006 09:00:35 -0700, John Machin wrote: > jason wrote: >> Hello, >> >> I am completely new to python and I have question that I unfortunately >> could not find in the various documentation online. My best guess is >> that the answer should be quitte easy but I have just enterd the >> learning phase so that means a hightend chance for stupidity and >> mistakes on my part. >>
<cut> ... </cut> Owww.. Of course... ! Thankx for the answer and the suggestion. It really helped me a lot. I defintely going to take the OO approach later on. thankx again for the quick reply. Jason. > You are *assigning* records = blahblah each time around. "records" will > end up being bound to the blahblah related to the *last* record that you > read. > > You can do it item by item: > records[folder]['date'] = datum > etc > or as a oneliner: > records[folder] = {'date' : datum, 'mesgbytes' : > extrmsize(str[8:]), 'mesgcount' : 1} > > When you find yourself using a dictionary with constant keys like > 'date', it's time to start thinking OO. > > class LogMessage(object): > def __init__(self, date, .....) > self.date = date > etc > > then later: > > records[folder] = LogMessage( > date=datum, > mesgbytes= extrmsize(str[8:]), > mesgcount=1, > ) > > > [snip] > > HTH, > John -- http://mail.python.org/mailman/listinfo/python-list