Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > doubt with importing module, given module name

Thread Tools

doubt with importing module, given module name

Pradnyesh Sawant
Posts: n/a
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 ""
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
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing module with name given as a variable Bruno Desthuilliers Python 1 08-30-2008 06:02 PM
" Given BACK what was freely GIVEN " C++ 0 12-13-2006 02:56 AM
Days in a given date range for a given month......... Lord0 Java 1 04-19-2006 04:54 PM
generate all possible strings of given length given a set of characters chiara C Programming 6 10-06-2005 01:43 AM
How to keep a module with the same name as a module it is importing from importing itself? plb Python 2 02-08-2005 03:14 PM