Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'skip:[ 20': 0.04; 'importing': 0.05; 'interpreter.': 0.07; 'broke': 0.09; 'exit': 0.09; 'restart': 0.09; 'marco': 0.16; 'subject:Clearing': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'module': 0.19; 'working.': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; "skip:' 10": 0.31; "d'aprano": 0.31; 'steven': 0.31; 'phone:': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'so,': 0.37; 'easiest': 0.38; 'stopped': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'more': 0.64; 'charset:windows-1252': 0.65; 'header:Reply-To:1': 0.67; 'sharing': 0.69; 'reply-to:no real name:2**0': 0.71; 'received :mail-wi0-x229.google.com': 0.91; 'recover': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:message-id:date:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=d7UpxmrOs9maQQIu1O+d0GerlV2U39TmFfurOKXHeac=; b=QQxjxLzElRVKeRuFjEwEbO+e1p8CkqsiOn8s7XjF+1SR1FdYsTKGK2Sgjy1wkH9eWa Z7bIwTt1Q24Icwl809iyTntueRgiTdrSF3Sfbq+3hOpTgyf6MZ799VqpSaknpPAyT0YE rnFxIAhejG7jkwQmRivDcbqSyHw3/FhxI9Fo/qdzs7pfmBCuZtHXNM8EXNIGi2LMmw7o JBbksjZRsJquVls/hzDus6n5EzRoFebEc7e3j61qp28Ia60J9kSB8tk4l7A9NIzm1v3c JoVW4KTphX12GFhhDfQvmEgfq/2vccXL+Y4fCqRNurSjnHKKfFRVuwq6yX4L0RsBz59S VZnQ== X-Received: by 10.194.58.13 with SMTP id m13mr5602735wjq.134.1412181564101; Wed, 01 Oct 2014 09:39:24 -0700 (PDT) From: Marco Buttu X-Google-Original-From: Marco Buttu Date: Wed, 01 Oct 2014 18:39:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Clearing globals in CPython References: <542c2527$0$13013$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <542c2527$0$13013$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Thu, 02 Oct 2014 15:46:17 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: mbuttu@oa-cagliari.inaf.it List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412257578 news.xs4all.nl 2975 [2001:888:2000:d::a6]:36994 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4177 X-Received-Body-CRC: 1833371300 Xref: csiph.com comp.lang.python:78604 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 current session and > restart it, but as a challenge, can we recover from this state? >>> [].__class__.__module__ # It is a string... '__builtin__' So, I do not have any idea about how to get a module without importing something. Thanks for sharing :) -- Marco Buttu INAF-Osservatorio Astronomico di Cagliari Via della Scienza n. 5, 09047 Selargius (CA) Phone: 070 711 80 217 Email: mbuttu@oa-cagliari.inaf.it