30 April, 2010

Python: Import a Module and Get a given Class

Python offers different ways to import a module. The most flexible one is to use __import__ function. This allows script to load a module dynamically. So we can load a particular module based on user input.

Since everything in python is an object even the python module has some useful properties. One of them is __dict__ property. This is how you can use it.