Simple question regarding module initialization

Patrick M. Nielsen thirsteh at gmail.com
Tue Jun 20 21:46:28 EDT 2006


Hi guys.

Yes, this is very much a neophyte question, but I was pondering;

modules = ['stackless',
           'sys',
           'slsocket as socket',
           'random, time',
           'traceback',
           'string',
           'util']

for module in modules:
    print "Loading %s..." % module
    exec 'import %s' % module


Although I like the outcome of writing it like this, I don't feel good about
it. Is this against standard Python conventions or morals? Loading modules
this way, that is (instead of just importing it all "the right way" and
making a print statement for each one).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060621/8cfd7979/attachment.html>


More information about the Python-list mailing list