classification
Title: Clearing globals; interpreter -- IDLE difference
Type: behavior Stage: test needed
Components: IDLE Versions: Python 3.0
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, gpolo, terry.reedy
Priority: low Keywords:

Created on 2008-09-22 22:45 by terry.reedy, last changed 2009-04-26 22:14 by ajaksu2.

Messages (2)
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) Date: 2009-04-26 22:14
If intended, should be documented somewhere, right?
History
Date User Action Args
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