Then change the way your program is set up :-)
Seriously, "from module import *" is generally a bad idea. Not always, but
generally, and in this specific instance I'm not sure that your use case
is one of those exceptions. However, be that as it may be, on to solving
When you "import foo" or "from module import foo", the name foo is bound
in the local scope, not global. In other words, the name foo will then
only exist inside the function. So this does not work:
... import string
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'string' is not defined
However this does work as you would expect:
... global math
... import math
<built-in function sin>
when you import. Keep in mind that it states that "from module import *"
in function blocks is explicitly stated to be an error, and in Python 2.3
a warning is raised:
... from math import *
<stdin>:1: SyntaxWarning: import * only allowed at module level
Should security be defined somewhere?
I'd consider putting your import logic into a module of its own, at
the module-level and not inside a function. Then just call "from importer
import *" in the top level of your code and I think that should meet your