Paweł Tomulik
2016-06-20 09:25:11 UTC
Hi,
I was just skimming through SWIG manual and found this snippet in docs
related to python imports
(http://swig.org/Doc3.0/SWIGDocumentation.html#Python_absrelimports)
from sys import version_info
if version_info >= (2, 7, 0):
from . import pkg2
import pkg1.pkg2.mod3
else:
import pkg2.mod3
del version_info
This is a code, which gets inserted by "swig -relativeimport" when
package/module things are used. It doesn't work in python < 2.5, because
relative import syntax (from . import pkg2) was introduced in 2.5:
Python 2.3.5 (#2, Oct 18 2006, 23:58:16)
[GCC 4.1.2 20061007 (prerelease) (Debian 4.1.1-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
File "<stdin>", line 1, in ?
File "pkg1/mod2.py", line 3
from . import pkg2
^
SyntaxError: invalid syntax
If it's a known issue (e.g. dropped support for py < 2.5) then just
don't mind (although it should be good to mention somewhere in docs
which versions of Python are supported).
Regards!
I was just skimming through SWIG manual and found this snippet in docs
related to python imports
(http://swig.org/Doc3.0/SWIGDocumentation.html#Python_absrelimports)
from sys import version_info
if version_info >= (2, 7, 0):
from . import pkg2
import pkg1.pkg2.mod3
else:
import pkg2.mod3
del version_info
This is a code, which gets inserted by "swig -relativeimport" when
package/module things are used. It doesn't work in python < 2.5, because
relative import syntax (from . import pkg2) was introduced in 2.5:
Python 2.3.5 (#2, Oct 18 2006, 23:58:16)
[GCC 4.1.2 20061007 (prerelease) (Debian 4.1.1-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import pkg1.mod2
Traceback (most recent call last):File "<stdin>", line 1, in ?
File "pkg1/mod2.py", line 3
from . import pkg2
^
SyntaxError: invalid syntax
If it's a known issue (e.g. dropped support for py < 2.5) then just
don't mind (although it should be good to mention somewhere in docs
which versions of Python are supported).
Regards!
--
Paweł Tomulik
Paweł Tomulik