[Python-Dev] Dropping init.py requirement for subpackages (original) (raw)
Phillip J. Eby pje at telecommunity.com
Wed Apr 26 22:52:33 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 ]
At 04:33 PM 4/26/2006 -0400, Joe Smith wrote:
It seems to me that the right way to fix this is to simply make a small change to the error message. On a failed import, have the code check if there is a directory that would have been the requested package if it had contained an init module. If there is then append a message like "You might be missing an init.py file".
It might also be good to check that the directory actually contained python modules.
This is a great idea, but might be hard to implement in practice with the current C implementation of import, at least for the general case.
But if we're talking about subpackages only, the common case is a one-element path, and for that case there might be something we could do.
(The number of path items is relevant because the existence of a correctly-named but init-less directory should not stop later path items from being searched, so the actual "error" occurs far from the point where the empty directory would've been detected.)
- 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 ]