View Full Version : [SOLVED] [Python] Using lists from different modules

May 8th, 2011, 11:13 PM
I'm building a program and would like to use a list I have build in a module.

def function:
. . . Code to build list. . . pow[] and off[]

print pow
print off

The code says that off is not defined. Any idea what is going on?

May 8th, 2011, 11:15 PM
def module?
You are declaring a function there.

May 8th, 2011, 11:18 PM
def module?
You are declaring a function there.

Yeah sorry, LOL busy and didn't pay attention to what I was writing :-(

May 8th, 2011, 11:39 PM
Nevermind. . . Just declared global worked great. . .

Tony Flury
May 9th, 2011, 07:46 AM
Avoid Globals if you can - wrap your lists in a class is a much better idea.

or have two functions - which return each list.

Or have one function that returns the two lists in a single return.

May 9th, 2011, 10:16 AM
Don't you just want to import the function from that module?

from modulename import functionname