[Python-Dev] warnings about missing __init__.py in toplevel directories
Ronald Oussoren
ronaldoussoren at mac.com
Sat May 27 15:24:11 CEST 2006
On 27-mei-2006, at 8:49, Martin v. Löwis wrote:
> Ronald Oussoren wrote:
>> Some time ago a warning was introduced for directories on sys.path
>> that don't contain an __init__.py but have the same name as a
>> package/
>> module that is being imported.
>>
>> Is it intentional that this triggers for toplevel imports? These
>> warnings are triggered in the build process for PyObjC, which is in
>> itself pretty harmless but very annoying.
>
> They were very close to not being harmless earlier this year: Python
> was almost changed to actually treat the directory as a package
> even if it does not contain an __init__.py. In that case, the
> directory
> itself would have been imported, not the thing inside. The warning
> is (also) a hint that you should do some renaming - future versions
> of Python might drop the need for __init__.
I'd do the renaming even if the warning would stay as a hint for
users that forgot to create the __init__ file, I'm trying to keep my
code warning free. I asked just to make sure that the warning is
intentional for toplevel packages (which it is), I vaguely recall
that there was some discussion about enabling the warning only for
subpackages.
Ronald
More information about the Python-Dev
mailing list