[Python-Dev] Dropping init.py requirement for subpackages (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Wed Apr 26 21:56:07 CEST 2006
- Previous message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Next message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Phillip J. Eby wrote:
My counter-proposal: to be considered a package, a directory must contain at least one module (which of course can be init). This allows the "is it a package?" question to be answered with only one directory read, as is the case now. Think of it also as a nudge in favor of "flat is better than nested".
I assume you want
import x.y
to fail if y is an empty directory (or non-empty, but without .py files). I don't see a value in implementing such a restriction. If there are no .py files in a tree, then there would be no point in importing it, so applications will typically not import an empty directory.
Implementing an expensive test that will never give a positive result and causes no problems if skipped should be skipped.
I can't see the problem this would cause to tools: they should assume any subdirectory can be a package, with all consequences this causes. If the consequences are undesirable, users should just stop putting non-package subdirectories into a package if they want to use the tool. However, I doubt there are undesirable consequences (although consequences might be surprising at first).
Regards, Martin
- Previous message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Next message: [Python-Dev] Dropping __init__.py requirement for subpackages
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]