[Python-ideas] [Python-Dev] If you shadow a module in the standard library that IDLE depends on, bad things happen
Steven D'Aprano
steve at pearwood.info
Sun Nov 1 10:06:33 EST 2015
On Mon, Nov 02, 2015 at 12:44:27AM +1100, Chris Angelico wrote:
> On Mon, Nov 2, 2015 at 12:25 AM, Alexander Walters
> <tritium-list at sdamon.com> wrote:
> > If you are worrying about shadowing ONLY the standard library - guess
> > what? those names don't change often, and are well known. Don't use those
> > names.
>
> Well known? Okay. No cheating now! Which of these names will shadow
> something from the standard library, and which don't?
>
> code.py
> cgi.py
> chunk.py
[...]
Does it matter? It really only matters if you shadow something that gets
imported.
It's not exactly great practice to name your script "code.py", but if
you do, and it doesn't directly or indirectly try to import the code
library, it's harmless. That's why it is harmful to present users with
an alert (which they won't read) warning them that they're shadowing a
stdlib module.
--
Steve
More information about the Python-ideas
mailing list