On Mon, Nov 2, 2015 at 12:19 PM, Steven D'Aprano <st...@pearwood.info> wrote: > - Python as a whole should move "" from the start of sys.path to the end (or > at least the middle, after the stdlib) so as to avoid accidental shadowing. > > - Even if Python doesn't do this, IDLE could do it, and could do it > immediately, without waiting for a new point release. IDLE is an > application, an IDE, not the Python interpreter, and like IPython or any > other IDE, it is perfectly entitled to behave differently from the vanilla > Python interpreter.
IDLE consists of two things: its own code, and a means of running user code. Conceptually, they're entirely separate - it's almost a coincidence that they happen to be using the same language. If the IDE wants to protect itself against running unexpected userland modules, it is absolutely allowed to do that, same as any other application is; it can remove "" from sys.path, or reposition it, or add traps to see where some_module.__file__ is, or anything at all. But when it's running user code, it should be semantically as close as possible to the command-line interpreter as it can be. If I type "import foo" into IDLE's interactive mode, or if I type "import foo" into IDLE's editor and hit Run, or if I type "import foo" into the standard command-line interactive interpreter, I expect that they'll all find the same module, and if they don't, it's an extra debugging hassle. When I'm debugging a script, I'll often try some parts of it in an interactive interpreter, and it should not matter whether I pick "python", or Idle, or ipython in a terminal window, or the in-browser ipython notebook, etc, etc, etc. I want to be able to keep the differences *in my head*. There are already a few; interactive interpreters... * Can't have blank lines in class/function definitions; * Automatically print non-None expression results; * Recover from exceptions by returning to the main loop, rather than bombing the whole module load * Warnings are enabled by default AFAIK, all of these are consistent across _all_ interactive Python interpreters. (The second one is configurable, but it's always the default.) I do *not* want to have to add "Local modules do not shadow stdlib modules" as an additional difference, particularly not in one specific interface and not others. So yes, technically IDLE is allowed to behave differently. But I would hope this is extremely rare and VERY solidly justified (eg "Python 3.6 will do it this way, and IDLE is a bit ahead of the curve"). ChrisA -- https://mail.python.org/mailman/listinfo/python-list