Re: Clearing globals in CPython

2014-10-06 Thread Chris Angelico
On Mon, Oct 6, 2014 at 8:08 PM, Steven D'Aprano wrote: > On Mon, 06 Oct 2014 09:05:17 +, jakubo wrote: > >> After invoking autocompletion (.__ and hitting tab), session has been >> automagically healed. > > > That's ... um ... > > I have no words. > > > Can you confirm that autocompletion modi

Re: Clearing globals in CPython

2014-10-06 Thread Steven D'Aprano
On Mon, 06 Oct 2014 09:05:17 +, jakubo wrote: > After invoking autocompletion (.__ and hitting tab), session has been > automagically healed. That's ... um ... I have no words. Can you confirm that autocompletion modifies globals()? I don't have 3.4 installed here. -- Steven -- https

Re: Clearing globals in CPython

2014-10-06 Thread jakubo
On 2014-10-01, Peter Otten <__pete...@web.de> wrote: > Steven D'Aprano wrote: > >> Out of curiosity, I ran: >> >> globals().clear() >> >> Oops. >> >> So, with no built-ins available, import no longer works. That makes things >> rather tricky. >> >> Obviously the easiest way to recover is to exi

Re: Clearing globals in CPython

2014-10-02 Thread Stefan Behnel
Chris Angelico schrieb am 02.10.2014 um 16:12: > On Fri, Oct 3, 2014 at 12:07 AM, Grant Edwards wrote: >> On 2014-10-01, Steven D'Aprano wrote: >> >>> Obviously the easiest way to recover is to exit the current session and >>> restart it, but as a challenge, can we recover from this state? >> >> Py

Re: Clearing globals in CPython

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 12:07 AM, Grant Edwards wrote: > On 2014-10-01, Steven D'Aprano wrote: > >> Obviously the easiest way to recover is to exit the current session and >> restart it, but as a challenge, can we recover from this state? > > Python apparently _does_ need a "restart command". App

Re: Clearing globals in CPython

2014-10-02 Thread Grant Edwards
On 2014-10-01, Steven D'Aprano wrote: > Obviously the easiest way to recover is to exit the current session and > restart it, but as a challenge, can we recover from this state? Python apparently _does_ need a "restart command". -- Grant Edwards grant.b.edwardsYow! The PI

Re: Clearing globals in CPython

2014-10-02 Thread Marco Buttu
On 01/10/2014 18:00, Steven D'Aprano wrote: Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. Interesting... :D Obviously the easiest way to recover is to exit the c

Re: Clearing globals in CPython

2014-10-02 Thread Mark Lawrence
On 02/10/2014 09:11, Steven D'Aprano wrote: Peter Otten wrote: Steven D'Aprano wrote: Obviously the easiest way to recover is to exit the current session and restart it, but as a challenge, can we recover from this state? $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]

Re: Clearing globals in CPython

2014-10-02 Thread Steven D'Aprano
Peter Otten wrote: > Steven D'Aprano wrote: >> Obviously the easiest way to recover is to exit the current session and >> restart it, but as a challenge, can we recover from this state? > > $ python3 > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > [GCC 4.8.2] on linux > Type "help", "copyright

Re: Clearing globals in CPython

2014-10-01 Thread Terry Reedy
On 10/1/2014 12:00 PM, Steven D'Aprano wrote: Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. As you discovered, this reduces the interpreter to a pure syntax machine

Re: Clearing globals in CPython

2014-10-01 Thread Mark Lawrence
On 01/10/2014 17:00, Steven D'Aprano wrote: Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. I expected that global variables would be all lost, but built-ins would rem

Re: Clearing globals in CPython

2014-10-01 Thread Peter Otten
Steven D'Aprano wrote: > Out of curiosity, I ran: > > globals().clear() > > in the interactive interpreter. It broke much more than I expected! > Built-ins were no longer available, and import stopped working. > > I expected that global variables would be all lost, but built-ins would > remain,

Re: Clearing globals in CPython

2014-10-01 Thread Chris Kaynor
On Wed, Oct 1, 2014 at 9:14 AM, Chris Angelico wrote: > On Thu, Oct 2, 2014 at 2:00 AM, Steven D'Aprano > wrote: > > Obviously the easiest way to recover is to exit the current session and > > restart it, but as a challenge, can we recover from this state? > > Oooh interesting. This is kinda lik

Re: Clearing globals in CPython

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 2:00 AM, Steven D'Aprano wrote: > Obviously the easiest way to recover is to exit the current session and > restart it, but as a challenge, can we recover from this state? Oooh interesting. This is kinda like breaking out of a sandbox, and I know there are people here who a

Clearing globals in CPython

2014-10-01 Thread Steven D'Aprano
Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. I expected that global variables would be all lost, but built-ins would remain, since they don't live in the global names