Re: Semi-Newbie needs a little help

2009-07-07 Thread Piet van Oostrum
Nile nile_mcad...@yahoo.com (N) wrote: N I initialized the dictionary earlier in the program like this - N hashtable = {} N I changed the dict to hashtable but I still get the same result N I will try to learn about the defaultdict but I'm just trying to keep N it as simple as I can for now

Re: Semi-Newbie needs a little help

2009-07-07 Thread Nile
Thanks all for your help. I appreciate it. The problem was in the function. A simple bug which I should have caught but I had my mental blinders on and was sure the problem was outside the function. The answers have given me a lot to learn so thanks for that as well. --

Semi-Newbie needs a little help

2009-07-06 Thread Nile
I am trying to write a simple little program to do some elementary stock market analysis. I read lines, send each line to a function and then the function returns a date which serves as a key to a dictionary. Each time a date is returned I want to increment the value associated with that date.

Re: Semi-Newbie needs a little help

2009-07-06 Thread Chris Rebert
On Mon, Jul 6, 2009 at 3:02 PM, Nilenile_mcad...@yahoo.com wrote: I am trying to write a simple little program to do some elementary stock market analysis.  I read lines, send each line to a function and then the function returns a date which serves as a key to a dictionary. Each time a date

Re: Semi-Newbie needs a little help

2009-07-06 Thread Pablo Torres N.
On Mon, Jul 6, 2009 at 17:02, Nilenile_mcad...@yahoo.com wrote: Code    for x in range(len(file_list)):    d = open(file_list[x] , r)    data = d.readlines()    k = above_or_below(data)                                # This function seems to work correctly    print here is the value that

Re: Semi-Newbie needs a little help

2009-07-06 Thread MRAB
Chris Rebert wrote: On Mon, Jul 6, 2009 at 3:02 PM, Nilenile_mcad...@yahoo.com wrote: I am trying to write a simple little program to do some elementary stock market analysis. I read lines, send each line to a function and then the function returns a date which serves as a key to a dictionary.

Re: Semi-Newbie needs a little help

2009-07-06 Thread Nile
On Jul 6, 5:30 pm, Pablo Torres N. tn.pa...@gmail.com wrote: On Mon, Jul 6, 2009 at 17:02, Nilenile_mcad...@yahoo.com wrote: Code    for x in range(len(file_list)):    d = open(file_list[x] , r)    data = d.readlines()    k = above_or_below(data)                                # This

Re: Semi-Newbie needs a little help

2009-07-06 Thread Nile
On Jul 6, 5:22 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Jul 6, 2009 at 3:02 PM, Nilenile_mcad...@yahoo.com wrote: I am trying to write a simple little program to do some elementary stock market analysis.  I read lines, send each line to a function and then the function returns a

Re: Semi-Newbie needs a little help

2009-07-06 Thread Rhodri James
On Tue, 07 Jul 2009 00:29:36 +0100, Nile nile_mcad...@yahoo.com wrote: Revised code for x in range(len(file_list)): d = open(file_list[x] , r) data = d.readlines() k = 0 k = above_or_below(data) print here is the value that was returned ,k

Re: Semi-Newbie needs a little help

2009-07-06 Thread Dave Angel
MRAB wrote: div class=moz-text-flowed style=font-family: -moz-fixedNile wrote: [snip] I initialized the dictionary earlier in the program like this - hashtable = {} I changed the dict to hashtable but I still get the same result I will try to learn about the defaultdict but I'm just trying

Re: Semi-Newbie needs a little help

2009-07-06 Thread Gabriel Genellina
En Mon, 06 Jul 2009 19:49:41 -0300, MRAB pyt...@mrabarnett.plus.com escribió: Chris Rebert wrote: from collections import defaultdict counts = defaultdict(lambda: 0) Better is: counts = defaultdict(int) For speed? This is even faster: zerogen = itertools.repeat(0).next counts =