S
Stefaan Himpe
Hello list,
Recently someone asked me this question, to which I could not give an
answer. I'm hoping for some insight, or a manual page. What follows is
python 2.6.
The problem is with the difference between
from test import *
and
import test
First things first. Here's the code to test.py:
a = 3
def f():
global a
return a
Now, in the interactive interpreter:
3
in a second session:
4
Somehow, in the first session I cannot modify the global variable a
returned from f, but in the second session I can. To my eye, the only
difference seems to be a namespace. Can anyone shine some light on this
matter?
Thanks,
Stefaan.
Recently someone asked me this question, to which I could not give an
answer. I'm hoping for some insight, or a manual page. What follows is
python 2.6.
The problem is with the difference between
from test import *
and
import test
First things first. Here's the code to test.py:
a = 3
def f():
global a
return a
Now, in the interactive interpreter:
3
in a second session:
4
Somehow, in the first session I cannot modify the global variable a
returned from f, but in the second session I can. To my eye, the only
difference seems to be a namespace. Can anyone shine some light on this
matter?
Thanks,
Stefaan.