why import * only allowed at module level?

Simo Salminen this at is.invalid
Sun Jan 13 23:07:11 EST 2002

How come python 2.2 does not allow code like this:

>>> def a():
... 	from os import *
<interactive input>:1: SyntaxWarning: import * only allowed at module level

Why this was changed? I like to do import * at function level because
it is handy but doesn't pollute namespace.

simo <dot> salminen <at> iki <dot> fi

More information about the Python-list mailing list