R. David Murray added the comment:
Is it the case that given a filename, it might be possible to load a module
even if open(filename) fails?
I think the logic is clearer in the form where it is not pulled out into a
separate helper function. You can avoid the double check on the extension by
doing:
if filename.endswith(importlib.machinery.BYTECODE_SUFFIXES):
loader = importlib.machinery.SourcelessFileLoader('__temp__',
filename)
elif filename.endswith(importlib.machinery.EXTENSION_SUFFIXES):
loader = importlib.machinery.ExtensionFileLoader('__temp__',
filename)
else:
loader = None
if loader:
xxxxx
else:
xxxxx
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20123>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com