Dynamic Imports
Let's learn how importlib is useful in dynamic imports.
We'll cover the following
How importlib is useful
The importlib
module supports the ability to import a module that is
passed to it as a string.
Getting started with dynamic imports
So let’s create a couple of simple modules that we can work with. We will give both modules the same interface, but have them print their names so we can tell the difference between the two. Create two modules with different names such as foo and bar and add the following code in each of them:
Get hands-on with 1400+ tech skills courses.