[New-bugs-announce] [issue23447] Relative imports with __all__ attribute

Antonio Cota report at bugs.python.org
Wed Feb 11 19:38:45 CET 2015


New submission from Antonio Cota:

That's the situation:

a/
  __init__.py
  first.py
  second.py

#init.py
__all__ = ['second', 'first']
print('i\'m starting the directory')

#first.py
print('hi, i\'m the first')
from . import *

#second.py
print('hi, i\'m the second')

>From the interactive prompt:
>>> import a.first
i'm starting the directory
hi, i'm the first
hi, i'm the second
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/antox/Scrivania/a/first.py", line 2, in <module>
    from . import *
AttributeError: module 'a' has no attribute 'first'

It's pretty weird.

----------
messages: 235761
nosy: antox
priority: normal
severity: normal
status: open
title: Relative imports with __all__ attribute
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23447>
_______________________________________


More information about the New-bugs-announce mailing list