Hans Dushanthakumar wrote:
> Oops answered my own question. Dynamic importing is done using the
> __import__ function:
> 
> t = ["test1.py", "test2.py"] #Actually this list is filled in by a
> Tkinter Listbox selection.
> 
> for f in t:
>     testname = f[:-3]
>     test = __import__("%s"%(testname))

If testname is a string, as it is here, "%s"%(testname) has the same 
value as testname itself, you can just use __import__(testname)

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to