Simpler Python module loading

Simplification possible given Python 2.7 is now the minimum supported.
Issue #848
This commit is contained in:
William S Fulton 2018-12-18 07:25:40 +00:00
commit 2a00d0f784
2 changed files with 15 additions and 22 deletions

View file

@ -6282,13 +6282,10 @@ The code is generated into the pure Python module, foo.py, and merely imports th
<div class="targetlang">
<pre>
def swig_import_helper():
import importlib
pkg = __package__ if __package__ else __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_foo')).lstrip('.')
return importlib.import_module(mname)
_foo = swig_import_helper()
del swig_import_helper
if __package__ or __name__.rpartition('.')[0]:
from . import _foo
else:
import _foo
</pre>
</div>