Path: csiph.com!news.swapon.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:51:39 -0800 Lines: 15 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 LnakCl2wx9AiO9XaZzVZxQIbRCp678esbvv5rVAT9rpw== 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; 'see.': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'subject:module': 0.09; 'intuition': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:import': 0.16; 'wrote:': 0.16; 'module,': 0.18; 'visible': 0.22; 'am,': 0.23; 'code.': 0.23; 'import': 0.24; 'patch': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'module.': 0.27; 'dan': 0.29; '~ethan~': 0.29; 'should': 0.36; 'modules': 0.36; 'to:addr:python- list': 0.36; 'say': 0.37; 'anything': 0.38; 'sure': 0.39; 'does': 0.39; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'telling': 0.61; 'charset:windows-1252': 0.62; 'subject:; ': 0.91 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: 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:103507 On 02/25/2016 08:20 AM, Dan Stromberg wrote: > My intuition is telling me that "module.data; module.data.mutate()" > would be easier to monkey patch in a way that all modules will see. > Is that fair to say? It is fair to say that if you need to monkey-patch a module, you should import the module. :) You should also import it before anything else does to make sure your change is visible to all other code. -- ~Ethan~