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 terry.reedy
Recipients Alex-Python-Programmer, epaine, terry.reedy
Date 2020-07-14.23:14:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594768440.48.0.0223122217728.issue41278@roundup.psfhosted.org>
In-reply-to
Content
Although a few keystrokes are omitted, I reproduced the examples and can explain the results by elaborating on my claims above.

0. Python starts execution in module '__main__', which initially contains only double underscore names (now 7).

1. If a module name is not in the user code main namespace, IDLE checks in sys.modules, which initially contains '__main__' and many others.

2. 'fetch_completions' returns two completion lists: big, with all appropriate names, and small, without underscore names.  If big is not empty, the initial display is small if not empty, else big. 

Hence, at startup, '__main__.' displays the big list with 7 dunder names because small is empty.  Assign to *any* 'normal' name, so that small contains 1 name, and '__main__.' initially displays that 1 name.  There is nothing special about 'idlelib' here.

The above is true when editing.

3. When there is no Shell, there is no user process, the same as if one started IDLE with -n to never have a separate user process.  When there is no user process, completions are done in the IDLE GUI process, and its main module contains 'idlelib' from IDLE's startup imports.  So the small completion list contains 'idlelib'.

For '__main__.x' to run, there must be a previous 'import __main__'.  If one runs the editor code after entering import statements, as the doc recommends, a user process will be started.


*** I just edited the IDLE completion doc, but 1, 2, and 3 could be made clearer.  I am leaving this issue open to do so. ***
History
Date User Action Args
2020-07-14 23:14:00terry.reedysetrecipients: + terry.reedy, Alex-Python-Programmer, epaine
2020-07-14 23:14:00terry.reedysetmessageid: <1594768440.48.0.0223122217728.issue41278@roundup.psfhosted.org>
2020-07-14 23:14:00terry.reedylinkissue41278 messages
2020-07-14 23:14:00terry.reedycreate