Gerrit Holl wrote:
Ed Leafe wrote:

On Mar 7, 2005, at 5:23 AM, Michael Hoffman wrote:

Avoiding exec (which is a statement, not a function) is much more
important. Since it executes arbitrary code, you can get unpredictable
results from it.

Is there any way to use __import__ to replace the following:

exec("from %s import *" % modulename)

> No.

Between the following two recipes, it seems unlikely that a simple
"No" is really correct:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/223972

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/307772

A variation on some of the code therein should certainly be
able to do the equivalent of "from xx import *".  (The addition
of support for __all__ is at least required for full emulation.)

-Peter
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to