doubt with importing module, given module name

Pradnyesh Sawant spradml at gmail.com
Wed Apr 11 13:28:07 EDT 2007


> module_name = "module"
> mod = __import__(module_name)
> class_name = module_name.capitalize()
> cls = getattr(mod, class_name)
> inst = cls()
>
Worked like a magic charm :) Also helped me understand the concept of getattr :D
Thanks a million!
--
warm regards,
Pradnyesh Sawant
--
Be yourself......everyone else is taken. --Anon



More information about the Python-list mailing list