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
> 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
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
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
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.
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
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
> >
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
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
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
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
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
12 matches
Mail list logo