Path: csiph.com!feeder.erje.net!2.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ethan Furman Newsgroups: comp.lang.python Subject: Re: "from module import data; print(data)" vs "import module; print(module.data)" Date: Thu, 25 Feb 2016 08:35:52 -0800 Lines: 14 Message-ID: References: <56ce7762$0$11100$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de OfAM+N5Vl1QchoKoa9kCtww6VIspIUEKuruf99gAZhqA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(b)': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'imported': 0.09; 'message- id:@stoneleaf.us': 0.09; 'subject:module': 0.09; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:import': 0.16; 'wrote:': 0.16; 'module,': 0.18; '(a)': 0.22; 'affects': 0.22; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User- Agent:1': 0.26; 'relies': 0.29; '~ethan~': 0.29; "d'aprano": 0.33; 'steven': 0.33; 'done': 0.35; 'to:addr:python-list': 0.36; 'pm,': 0.36; '(2)': 0.37; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'charset:windows-1252': 0.62; 'more': 0.63; 'different': 0.63; 'therefore': 0.67; 'subject:; ': 0.91 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <56ce7762$0$11100$c3e8da3@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103506 On 02/24/2016 07:39 PM, Steven D'Aprano wrote: > (2) import module > > (a) Mutation is no different from (1)(a) above. No change. > > (b) Rebinding `module.data = []` affects the imported module, and therefore > everything that relies on it. More accurate: and therefore everything that has not already done a `from module import data` as those will be unaffected by the rebinding. -- ~Ethan~