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.

classification
Title: Clearing globals; interpreter -- IDLE difference
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, ajaksu2, georg.brandl, gpolo, roger.serwy, terry.reedy
Priority: low Keywords:

Created on 2008-09-22 22:45 by terry.reedy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg73603 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2008-09-22 22:44
Interpreter:
>>> globals()
{'__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__',
'__doc__': None, '__package__': None}
>>> globals().clear()
>>> globals()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'globals' is not defined

Though not what one would usually want, .clear() clears all.  One now
has a bare interpreter with import disabled ('__import__' not found).

IDLE:
>>> globals().clear()
>>> __name__
'builtins'
>>> globals()
{'__builtins__': {'bytearray': <class 'bytearray'>,...

Module builtins has become the main module. Assignments are added to the
__builtins__ dict.  I am not sure if this is intended or a bug, but if
IDLE is trying to 'recover' from the 'disabling' of the main module, I
think 'Restart Shell ^F6' would be better.
msg86616 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-26 22:14
If intended, should be documented somewhere, right?
msg185425 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-03-28 10:28
Terry, do you still think this is important to fix?
msg185445 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-03-28 13:06
I would like to discuss it with other IDLE devs (Roger) after fixing more important issues.
msg220125 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-09 23:03
The output from IDLE is still the same using both 3.4.1 and 3.5.  FTR the output from iPython 2.0.0 appears the same, although it's pretty printed.
msg220131 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-10 00:20
I decided that anyone with a use case for a bare interpreter, if there is such a person, would and should be using the console, and that a closed issue is sufficient documentation for now.
History
Date User Action Args
2022-04-11 14:56:39adminsetgithub: 48188
2014-06-10 00:20:54terry.reedysetstatus: open -> closed
resolution: wont fix
messages: + msg220131

stage: test needed -> resolved
2014-06-09 23:03:00BreamoreBoysetnosy: + BreamoreBoy

messages: + msg220125
versions: + Python 3.5, - Python 3.3
2013-03-28 14:02:11roger.serwysetnosy: + roger.serwy
2013-03-28 13:06:47terry.reedysetmessages: + msg185445
2013-03-28 10:28:38georg.brandlsetnosy: + georg.brandl

messages: + msg185425
versions: + Python 2.7, Python 3.3, Python 3.4, - Python 3.0
2009-04-26 22:14:06ajaksu2setnosy: + ajaksu2, gpolo
messages: + msg86616

type: behavior
stage: test needed
2008-09-22 22:56:00loewissetpriority: low
2008-09-22 22:45:01terry.reedycreate