command-line args

Peter Hansen peter at engcorp.com
Sat Apr 24 22:17:08 EDT 2004


Cameron Laird wrote:

> You seem to have given Michael everything he needed.  I don't
> get it, though.  Why must "some code that needs to know the
> timeout" import globals?  In what context would it not already
> be present?

We're on different wavelengths, obviously, because I don't
even understand your question.  Let's try to find the source of
the misunderstanding.  Here's my take on it:

Assuming we're both accepting that the "timeout" value is stored
only in a module called globals, and in Python a module is not
available in another module unless there is a prior "import"
statement importing the required module, it seems to me that
code in another module which needs to use "timeout" *must*
do an "import globals" first.

Having written that, I'm guessing you are thinking about only
one module, where "import globals" occurred at the top, and
the arg parsing code then executed, and then later on some
other code in the same module needed to get to "timeout".
In that case clearly "it would already be present".

-Peter



More information about the Python-list mailing list