Tuesday, August 16, 2005

Reading a file and then interactive mode

This was is quite simple.

$python -i scriptname

Importing modules in a loop

I first wrote up the unsafe way of doing it using exec

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)