Tom Strickland wrote:

>>Here are the modules in question:
>>  
>>
> ####This is the main.py module
>
> #!/usr/bin/python2.4
> import enterData
> import movAvg
> smavg=[]
> xy=enterData.close
> print xy[0]   
> smavg = movAvg.sma(20,enterData.close)
> emavg=[]
> emavg=movAvg.ema(20,enterData.close)
> import stoResults
> stoResults.store(enterData.date, enterData.close,smavg,emavg)
> print "Finished"
>
>
> ######This is the enterData.py module
> ##!/usr/bin/python2.4
> input = open('/home/tom/Python/Input/SPY2.csv', 'r')
> s = input
> date =[]
> open = []
> close = []
> hi = []
> lo = []
> vol = []
> for s in input:
>     s = s[:-2]
>     y =[]
>     y = s.split(',')
>     date.append(y[0])
>     open.append(float(y[1]))
>     hi.append(float(y[2]))
>     lo.append(float(y[3]))
>     close.append(float(y[4]))
>     vol.append(float(y[5]))
> input.close()
> for i in range(5):
>     print close[i]
> print 'enterData.py'
>
>
>    
>
> ***********************************************************************************************************************************
>  
>
>
>>------------------------------
>>
>>Message: 7
>>Date: Sat, 27 Aug 2005 22:27:23 -0500
>>From: Tom Strickland <[EMAIL PROTECTED]>
>>Subject: [Tutor] Importing a List from Module
>>To: tutor@python.org
>>Message-ID: <[EMAIL PROTECTED]>
>>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>>I have a module called "enterData" which generates a list, "close" from 
>>a data file. "close" is a list of floats. When I put a print statement 
>>in that module it will print out an individual member of the list. For 
>>example,
>>
>>    print close[0]
>>
>>
>>prints the first member of the list.
>>
>>In my "main" module I import "enterData" and try to read the first 
>>element of "close" as follows:
>>
>>    import enterData
>>    xy=enterData.close
>>    print xy[0]   
>>
>>
>>When I do this it prints out the entire "close" list, not just the first 
>>term.
>>
>>What's my mistake and how do I correct it?
>>
>>Thank you!
>>
>>
>>------------------------------
>>
>>Message: 8
>>Date: Sun, 28 Aug 2005 00:15:15 -0400
>>From: Kent Johnson <[EMAIL PROTECTED]>
>>Subject: Re: [Tutor] Importing a List from Module
>>Cc: tutor@python.org
>>Message-ID: <[EMAIL PROTECTED]>
>>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>>Tom Strickland wrote:
>>  
>>
>>>I have a module called "enterData" which generates a list, "close" from 
>>>a data file. "close" is a list of floats. When I put a print statement 
>>>in that module it will print out an individual member of the list. For 
>>>example,
>>>
>>>    print close[0]
>>>
>>>
>>>prints the first member of the list.
>>>
>>>In my "main" module I import "enterData" and try to read the first 
>>>element of "close" as follows:
>>>
>>>    import enterData
>>>    xy=enterData.close
>>>    print xy[0]   
>>>
>>>
>>>When I do this it prints out the entire "close" list, not just the first 
>>>term.
>>>
>>>What's my mistake and how do I correct it?
>>>    
>>>
>>
>>What you have shown here looks fine to me. Can you show some more of 
>>enterData?
>>
>>Kent
>>
>>
>>
>>------------------------------
>>
>>Message: 9
>>Date: Sat, 27 Aug 2005 21:25:36 -0700
>>From: Byron <[EMAIL PROTECTED]>
>>Subject: Re: [Tutor] Importing a List from Module
>>To: Tom Strickland <[EMAIL PROTECTED]>, tutor@python.org
>>Message-ID: <[EMAIL PROTECTED]>
>>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>>Tom Strickland wrote:
>>  
>>
>>>In my "main" module I import "enterData" and try to read the first 
>>>element of "close" as follows:
>>>
>>>    import enterData
>>>    xy=enterData.close
>>>    print xy[0]   
>>>
>>>
>>>When I do this it prints out the entire "close" list, not just the first 
>>>term.
>>>    
>>>
>>
>>
>>Hi Tom,
>>
>>I would create a function in your module that returns the list.  Here's 
>>a quick, simplified example:
>>
>>def returnList():
>>      newList = []
>>      newList += [123.45]
>>      newList += [529.59]
>>      newList += [259.92]
>>      return newList
>>      
>>aList = returnList()
>>print aList
>>
>>
>>Note the return statement...  This enables assignment, as you have done 
>>in "xy=enterData.returnList()"
>>
>>Hope this helps,
>>
>>Byron
>>---
>>
>>
>>
>>------------------------------
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>End of Tutor Digest, Vol 18, Issue 106
>>**************************************
>>
>>
>>  
>>
>


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to