Module Import Checking
Understand how to use Python's importlib module to check for module availability before importing, handle import errors using EAFP principles, and programmatically load modules using module specifications.
We'll cover the following...
We'll cover the following...
Why do we need importlib?
Python has a coding style that is known as EAFP: Easier to ask for
forgiveness than permission. What this means is that it’s often easier
to just assume that something exists (like a key in a dict) and catch an
exception if we’re wrong. We saw this previously where we would attempt to import a module and we caught the ImportError if it
didn’t exist. What if we ...