And on a related topic, how can I actually detect other types of
imports, for example
__import__
Doing a dump I get this:
In [113]: ast.dump(ast.parse('__import__("module")'))
Out[113]: "Module(body=[Expr(value=Call(func=Name(id='__import__',
ctx=Load()), args=[Str(s='module')], keywords=[], starargs=None,
kwargs=None))])"
So the visitor should be quite smart, and the string passed can't be
always be done.
I think the easiest way is just to use regexp and look for them warning
the user that there might be other
stupid imports, the harder way is to try to detect it and if the string
passed is actually known at compile-time
use it, otherwise warn the user.
--
http://mail.python.org/mailman/listinfo/python-list