As others said, the two forms are semantically the same. Later ( __import__('foo') ) is used when the module name is not known before execution. The most common examples of this are modules named in the configuration file or in the plugin loading system. Django configuration files, for example, define plug-in modules as strings (for example, some_plugin = 'foo.plugin' ) in the python configuration file, and Django loads these modules using __import__ .
source share