Skip to content

Instantly share code, notes, and snippets.

@bartekbrak
Created November 26, 2015 13:36
Show Gist options
  • Save bartekbrak/f2cb8efb581ad2603a64 to your computer and use it in GitHub Desktop.
Save bartekbrak/f2cb8efb581ad2603a64 to your computer and use it in GitHub Desktop.
$ cat re.py
print('local re being imported')
$ python2.6 -c 'import re'
local re being imported
$ python2.6 -c 'from __future__ import absolute_import;import re'
local re being imported
$ python2.6 -c 'from re import *'
local re being imported
$ python2.6 -c 'from .re import *'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: Attempted relative import in non-package
$ python2.7 -c 'import re'
$ python2.7 -c 'from __future__ import absolute_import;import re'
$ python2.7 -c 'from re import *'
$ python2.7 -c 'from .re import *'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: Attempted relative import in non-package
$ python3 -c 'import re'
local re being imported
$ python3 -c 'from __future__ import absolute_import;import re'
local re being imported
$ python3 -c 'from re import *'
local re being imported
$ python3 -c 'from .re import *'
local re being imported
Traceback (most recent call last):
File "<string>", line 1, in <module>
SystemError: Parent module '' not loaded, cannot perform relative import
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 28, in enabled
return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
AttributeError: 'module' object has no attribute 'search'
Original exception was:
Traceback (most recent call last):
File "<string>", line 1, in <module>
SystemError: Parent module '' not loaded, cannot perform relative import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment