namespace confusion
Mark Robinson
m.1.robinson at herts.ac.uk
Wed Aug 8 10:28:43 EDT 2001
Sorry, I didn't make that a very good example. I was really just trying
to show the structure so you could see that I couldn't access the
functions from one module, called by a function in a module other than
__main__. Sloppy, sorry. Nevertheless, swapping
import
for my
from 'whatever' import *
solves my problem. I was just being lazy and trying to avoid typing the
module names each time I called one of their functions
thanks
blobby
Duncan Booth wrote:
> The example you posted has several mistakes, so it isn't immediately
clear
> which are mistyping and which might be your actual problem.
> But I think the real problem is that you are using 'from module
import *'.
> This form of the import statement makes a copy of all the variables that
> exist in another module at the time when the import is executed. This is
> very rarely what you want. It is almost always better to just import the
> module and access the values when you need them. So second.py becomes:
>
> import first
>
> def functSecond():
> first.functfirst() #
>
> and provided you actually define the function in first this call should
> work.
More information about the Python-list
mailing list