[Tutor] Importing a List from Module
Tom Strickland
tlinux at comcast.net
Sun Aug 28 17:23:31 CEST 2005
Byron,
I'm confused (as usual). In "def returnList():" that you write below,
should the items in the newList list be close[i] and looped to fill
"newList" with the contents of "close"? If so, how is "returnLost"
different from "close"?
Thanks!
Tom
Byron wrote:
> 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
> ---
>
>
>
More information about the Tutor
mailing list