Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Question about math.pi is mutable Date: Mon, 9 Nov 2015 11:04:26 +1100 Lines: 24 Message-ID: References: <87d1vlzy4p.fsf@elektro.pacujo.net> <878u69zxww.fsf@elektro.pacujo.net> <563eba85$0$1611$c3e8da3$5496439d@news.astraweb.com> <87ziyowy83.fsf@elektro.pacujo.net> <8537wghwjb.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de IMen66sb0/z6MgNYkP2WmAvexx35XBuDcojVU4YlqTEQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Question': 0.05; 'cc:addr:python-list': 0.09; 'attribute.': 0.09; 'modules.': 0.09; 'python': 0.10; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'module).': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'any,': 0.18; 'typical': 0.18; 'tests': 0.18; 'library': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'essential': 0.20; 'am,': 0.23; '(or': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'module': 0.25; 'separate': 0.27; 'message-id:@mail.gmail.com': 0.27; 'module.': 0.27; 'objects': 0.29; 'you?': 0.30; 'creating': 0.30; 'another': 0.32; "can't": 0.32; 'run': 0.33; 'common': 0.33; 'changing': 0.34; 'that,': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'nov': 0.35; 'path': 0.35; 'quite': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'cases': 0.36; 'modules': 0.36; 'structures': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'names': 0.38; 'data': 0.39; 'does': 0.39; 'where': 0.40; 'some': 0.40; 'reach': 0.61; 'surprise': 0.72; '(actually,': 0.84; 'chrisa': 0.84; 'technique.': 0.84; 'to:none': 0.91; 'shadow': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=X2hjNCqhpb2a4ovYuX8WhxXru4WJRBgtve5GZlQuv/U=; b=OAdUEGogugLrV+bh9PSV/62yNLNqPvZcDbIDqMJ6Gqwps3907io3ohIJVP4KJ2fmjU FY/dtF3TsRrm7I1gJgNXt1yi3Gc4Htz1rDvn1oJJFVakdxK6pHdT4BqFeFuT9UF2yxwB oAdn37+YkWVfhCKF5J0K3Ulv61hhyxf8784rTXNUWvTGSz+t4K8pyHSfkkyRcZZF8/eq mTmcTK+/tyyyehL6v2FEsOc4vAuLzlbYDMrH+sQBCBoKQgv5qP6/xjkrh4+iD/1/HRpY MiHgSQFfOTXCFzhPdplmmX5W9STPBsAyplyihGJNgI5VKpdroKjnoGguWHK2yEp0egdT uLeg== X-Received: by 10.107.34.149 with SMTP id i143mr22418795ioi.157.1447027466563; Sun, 08 Nov 2015 16:04:26 -0800 (PST) In-Reply-To: <8537wghwjb.fsf@benfinney.id.au> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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:98487 On Mon, Nov 9, 2015 at 11:00 AM, Ben Finney wr= ote: > BartC writes: > >> Is this typical Python code? Creating global objects in other modules >> (or writing all over essential data structures in a library module). > > Not =E2=80=9Ccreating global objects=E2=80=9D, but changing the referent = of a name in > some other module. Yes, that's quite a common technique. Does that > surprise you? Changing the referent of an existing name, definitely. Creating new names, not so much. You don't often reach into another module and create a new attribute. Testing/mocking is a completely separate consideration (eg you can inject a shadow for a built-in name); if some Python implementation has a fast path that gets defeated by "module.int =3D MagicInt", and it causes the tests to run slower, so be it. Other than that, I can't think of many cases (actually, can't think of any, off hand) where you inject names into other modules. ChrisA