Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sys': 0.04; 'foo': 0.09; 'namespace': 0.09; 'pm,': 0.11; '>>>': 0.12; 'wrote:': 0.14; '-tkc': 0.16; '999': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'monkeys': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'subject:delete': 0.16; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'variable': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:addr :python-list': 0.22; 'modification': 0.23; 'module,': 0.23; 'changes': 0.29; 'cc:addr:python.org': 0.31; "skip:' 10": 0.32; 'import': 0.32; 'module': 0.33; 'received:70': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'references': 0.38; 'delete': 0.38; 'how': 0.39; 'banner': 0.80; 'beware': 0.84 Date: Tue, 29 Mar 2011 20:41:28 -0500 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: monkeys paw Subject: Re: delete namespaces References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301449303 news.xs4all.nl 34849 [::ffff:82.94.164.166]:51826 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2205 On 03/29/2011 08:14 PM, monkeys paw wrote: > How do i delete a module namespace once it has been imported? > > I use > > import banner > > Then i make a modification to banner.py. When i import it again, > the new changes are not reflected. Is there a global variable i can > modify? Delete it from sys.modules: >>> file('foo.py', 'w').write('x = 42\n') >>> import foo >>> foo.x 42 >>> del foo >>> import sys >>> del sys.modules['foo'] >>> file('foo.py', 'w').write('x = 999\n') >>> import foo >>> foo.x 999 Beware that if you still have old references to the module, they don't get refreshed. -tkc