[Tutor] Returning multiple values from a script
Kent Johnson
kent37 at tds.net
Thu Jan 12 02:47:56 CET 2006
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
More information about the Tutor
mailing list