This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients barry, brett.cannon, eric.snow, hakonhagland, ncoghlan, steven.daprano
Date 2017-05-30.00:32:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496104358.38.0.391002506193.issue30503@psf.upfronthosting.co.za>
In-reply-to
Content
This is just module shadowing in action. If you have two or more modules, or packages, in the module search path, the first one found will block access to the others.

> this is a bad design in my opinion.

*shrug* It is what it is.

Often it is inconvenient. Occasionally it is useful. It is the same way nearly all other languages with a library search path works: the compiler searches for a library until it finds a match, then stops.

How would you change this? Here are some unacceptable or impractical solutions:

- get rid of the search path, and force the programmer to specify the full file system path of every module (package) they import;

- use different syntax for importing a .py module and a package;

- after an import, if there's an error, Python should automatically re-do the import with the next module in the module search path;

- "I don't care how you fix it, that's your problem not mine".


I think the answer here is: don't do this. Don't use a package with the same name as a module.
History
Date User Action Args
2017-05-30 00:32:38steven.dapranosetrecipients: + steven.daprano, barry, brett.cannon, ncoghlan, eric.snow, hakonhagland
2017-05-30 00:32:38steven.dapranosetmessageid: <1496104358.38.0.391002506193.issue30503@psf.upfronthosting.co.za>
2017-05-30 00:32:38steven.dapranolinkissue30503 messages
2017-05-30 00:32:37steven.dapranocreate