newbie: from .. import *
jseb at cs.mcgill.ca
Fri Jun 14 00:37:38 CEST 2002
I've been working with Python for a while, but never really felt
confortable with the way namespaces are imported.
I'm working on a simple application that is to be used in the
interactive mode. The idea is that the behavior of a function is
determined, in part, by some global(?) flags. So I can change my
flags, and explicitely call my function. Really simple. Except that
for some reason, it does not work.
In "test.py", I have the following:
flag = 1
flag = 0
In the interactive mode, if I import the code above as:
>>> from test import *
The output is as expected. However, if I continue:
>>> flag = 1
(!) Okay... not what _I_ expected. It sounds really silly, but I've
spent a couple of hours on that, without success. I thought at some
point that using "global" would help me. Of course, if I just do
"import test", everything works fine --- but in interactive mode, I
don't want to type "test.foo()"
More information about the Python-list