Importing module with name given as a variable

  • Thread starter Bruno Desthuilliers
  • Start date
B

Bruno Desthuilliers

Sean Davis a écrit :
What is the "best practice" for importing an arbitrary module given
that the name is stored in a variable? The context is a simple web
application with URL dispatching to a module and function. I know of
__import__(), the imp module, and exec. For each of these, is there a
way to make them work "just like" the normal import call?

IIRC, this is documented in the __import__ function's doc.
 
S

Sean Davis

What is the "best practice" for importing an arbitrary module given
that the name is stored in a variable? The context is a simple web
application with URL dispatching to a module and function. I know of
__import__(), the imp module, and exec. For each of these, is there a
way to make them work "just like" the normal import call?

Thanks,
Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top