Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeder.erje.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subsequent': 0.04; 'cache': 0.05; 'key.': 0.07; 'before.': 0.09; 'imports': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'subject:dictionaries': 0.16; 'sys.modules': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'library,': 0.17; 'module,': 0.17; "shouldn't": 0.17; 'import': 0.21; 'thanks.': 0.21; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'usually': 0.30; 'another': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'october': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'real': 0.61; 'behavior': 0.64; 'otten': 0.84; 'seriously,': 0.91 Newsgroups: comp.lang.python Date: Tue, 9 Oct 2012 08:36:59 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=193.206.66.82; posting-account=gxxH8QkAAABVKeYyAqGOGoaFtdDdsshI References: <40ac555b-71c2-445e-814b-6bd1d037dbee@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 193.206.66.82 MIME-Version: 1.0 Subject: Re: surprising behaviour of global dictionaries From: Michele Simionato To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349797021 news.xs4all.nl 6969 [2001:888:2000:d::a6]:36926 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31041 On Tuesday, October 9, 2012 5:24:17 PM UTC+2, Peter Otten wrote: > Seriously, you shouldn't use the main script as a library; it is put into > > the sys.modules cache under the "__main__" key. Subsequent imports under its > > real name will not find that name in the cache and import another instance > > of the module, with puzzling effects Actually I usually never use the main script as a library, this is why I never experience this puzzling behavior before. But now it is clear, thanks.