On Apr 30, 1:10 pm, Dale Amon <a...@vnl.com> wrote: > I do not really see any other way to do what I want. If > there is a way to get rid of the exec in the sample code > I have used, I would love to know... but I can't see how > to import something where part of the name comes from user > command line input without interpreting the code via exec.
Are you familiar with __import__? iotypes = ["WINGTL","VLMPC","VLM4997"] for iotype in iotypes: packagename = "VLMLegacy." + iotype + ".Conditions" classname = iotype + "_Conditions" module = __import__(packagename) cls = getattr(module, classname) # etc Much cleaner :) And far more secure: any time you think "user input" AND "exec", you're probably going in the wrong direction... -- http://mail.python.org/mailman/listinfo/python-list