doubt with importing module, given module name

  • Thread starter Pradnyesh Sawant
  • Start date
P

Pradnyesh Sawant

Hello,
I have a string which in reality is the name of a module to be
imported. The name of the class contained in the module also has the
same (although with different capitalization). My requirement is to
import the module, and also create an instance of the class. eg:

str = "module" #name of module is "module.py"
cls = str.capitalize() #name of class is "Module"
inst = cls() #create an instance of class "Module"

how do i do this?

Thanks a lot in advance
 

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

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top