import and package confusion

Scott David Daniels Scott.Daniels at Acm.Org
Thu Apr 30 00:18:20 EDT 2009


Dale Amon wrote:
> On Wed, Apr 29, 2009 at 10:02:46PM -0400, Dave Angel wrote:
>> Please don't sink to exec or eval to solve what is really a  
>> straightforward problem.
> 
> 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.

at this point it would help to know what version of Python
you are using.  If importlib is available, use that.  Otherwise
you should investigate __import__.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list