Importing modules in a loop
I first wrote up the unsafe way of doing it using exec
But as using execs could be a bad habit ,the better way would be to use __import__
for script in ['power','cube']:
exec "import " + script
But as using execs could be a bad habit ,the better way would be to use __import__
for script in ['power','cube']:
__import__(script)

0 Comments:
Post a Comment
<< Home