I am working on Python 2.6 / 2.7 code that contains the following:
try: import gmpy gmpy_imported=True except ImportError: gmpy_imported=False if gmpy_imported and gmpy.__file__ is None: gmpy_imported=False
I can understand the try-except , which is used to see if gmpy is installed on the system, and if not, do anything. However, I do not understand why the check is needed if gmpy.__file__ is None ; it seems redundant.
Are there any circumstances when trying to import a package, but the package path would be empty? Is this a double check of failure-free protection against a damaged installation?
source share