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. -- http://mail.python.org/m

Re: Semi-Newbie needs a little help

2009-07-07 Thread Piet van Oostrum
> Nile (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 >N> R

Re: Semi-Newbie needs a little help

2009-07-06 Thread Gabriel Genellina
En Mon, 06 Jul 2009 19:49:41 -0300, MRAB 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 = defaultdict(zerogen) -- Gabriel Ge

Re: Semi-Newbie needs a little help

2009-07-06 Thread Dave Angel
MRAB wrote: Nile 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 to keep it as simple as I can for now Revised code f

Re: Semi-Newbie needs a little help

2009-07-06 Thread Rhodri James
On Tue, 07 Jul 2009 00:29:36 +0100, Nile 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 hashtable[k] = hashtable.

Re: Semi-Newbie needs a little help

2009-07-06 Thread MRAB
Nile 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 to keep it as simple as I can for now Revised code for x in range

Re: Semi-Newbie needs a little help

2009-07-06 Thread Nile
On Jul 6, 5:22 pm, Chris Rebert wrote: > On Mon, Jul 6, 2009 at 3:02 PM, Nile 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 > >

Re: Semi-Newbie needs a little help

2009-07-06 Thread Nile
On Jul 6, 5:30 pm, "Pablo Torres N." wrote: > On Mon, Jul 6, 2009 at 17:02, Nile 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

Re: Semi-Newbie needs a little help

2009-07-06 Thread MRAB
Chris Rebert wrote: On Mon, Jul 6, 2009 at 3:02 PM, Nile 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 is re

Re: Semi-Newbie needs a little help

2009-07-06 Thread Pablo Torres N.
On Mon, Jul 6, 2009 at 17:02, Nile 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 was returned

Re: Semi-Newbie needs a little help

2009-07-06 Thread Chris Rebert
On Mon, Jul 6, 2009 at 3:02 PM, Nile 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 is returned I want t

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. The