Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2a.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'example:': 0.03; 'amtsgericht': 0.07; 'hrb': 0.07; 'executed': 0.09; 'sure,': 0.09; 'python': 0.11; 'def': 0.12; 'differs': 0.16; 'namespace.': 0.16; 'rainer': 0.16; 'ralf': 0.16; 'statement.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'gmbh': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'germany': 0.24; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "i'm": 0.30; 'once,': 0.31; 'stuff': 0.32; 'themselves': 0.32; 'subject:from': 0.34; 'but': 0.35; 'las': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'matter': 0.61; 'times': 0.62; 'received:194': 0.64; 'skip:+ 10': 0.65; 'tel.:': 0.65; 'here': 0.66; 'press': 0.70; 'batchelder': 0.84; 'bla': 0.84; 'received:192.168.57': 0.84 Date: Thu, 23 Jan 2014 14:36:17 +0100 From: Johannes Schneider User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: SIngleton from __defaults__ References: <26ff768d-349c-48cd-a46f-25343807e18a@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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: , Newsgroups: comp.lang.python Message-ID: Lines: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390484172 news.xs4all.nl 2967 [2001:888:2000:d::a6]:44060 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64605 On 22.01.2014 20:18, Ned Batchelder wrote: > On 1/22/14 11:37 AM, Asaf Las wrote: > Chris is right here, too: modules are themselves singletons, no matter > how many times you import them, they are only executed once, and the > same module object is provided for each import. I'm not sure, if this is the whole truth. think about this example: cat bla.py a = 10 cat foo.py from bla import a def stuff(): return a cat bar.py from foo import stuff print stuff() a = 5 print stuff() from bla import * print a python bar.py 10 10 10 here the a is coming from bla and is known in the global namespace. But the value differs in stuff() and before/after the import statement. So the instance of the module differs -> it cannot be a singelton. bg, Johannes -- Johannes Schneider Webentwicklung johannes.schneider@galileo-press.de Tel.: +49.228.42150.xxx Galileo Press GmbH Rheinwerkallee 4 - 53227 Bonn - Germany Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax) http://www.galileo-press.de/ Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker HRB 8363 Amtsgericht Bonn