[Tutor] [Fwd: Re: Importing a List from Module]
Tom Strickland
tlinux at comcast.net
Sun Aug 28 23:38:50 CEST 2005
-------- Original Message --------
Subject: Re: Importing a List from Module
Date: Sun, 28 Aug 2005 16:37:26 -0500
From: Tom Strickland <strick_nine at comcast.net>
To: tutor at python.org
The problem has been solved. It turned out that I made a newbie mistake
that had nothing to do with importing lists. I have a function, sma,
which calculates the moving average for a list of prices. I passed the
"close" (subsequently changed to "cloze") list to the function as an
argument. There is a "for" loop in the function that appends close to a
new list.I had written this as:
p.append(close)
when it should have been
p.append(close[i])
This mistake caused the function to append the entire "close" list to
"p" instead of just "close[i]" each time through the loop which was more
than 4000 times.. This mistake caused a print statement to fill the
output screen with numbers. It was difficult to determine that my
problem wasn't importing "close", but in how I was using it.
Thanks to all who offered suggestions. While my use of "open" and
"close" as list names apparently didn't cause any problems, it's bad
form and I've changed those two names.
Tom
More information about the Tutor
mailing list