Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103506

Re: "from module import data; print(data)" vs "import module; print(module.data)"

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 <ethan@stoneleaf.us>
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 <mailman.130.1456418103.20994.python-list@python.org> (permalink)
References <mailman.111.1456362461.20994.python-list@python.org> <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 <ethan@stoneleaf.us>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:103506

Show key headers only | View raw


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~

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

"from module import data; print(data)" vs "import module; print(module.data)" Dan Stromberg <drsalists@gmail.com> - 2016-02-24 17:07 -0800
  Re: "from module import data; print(data)" vs "import module; print(module.data)" Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-02-25 14:39 +1100
    Re: "from module import data; print(data)" vs "import module; print(module.data)" Dan Stromberg <drsalists@gmail.com> - 2016-02-25 08:15 -0800
    Re: "from module import data; print(data)" vs "import module; print(module.data)" Dan Stromberg <drsalists@gmail.com> - 2016-02-25 08:20 -0800
    Re: "from module import data; print(data)" vs "import module; print(module.data)" Ethan Furman <ethan@stoneleaf.us> - 2016-02-25 08:35 -0800
    Re: "from module import data; print(data)" vs "import module; print(module.data)" Ethan Furman <ethan@stoneleaf.us> - 2016-02-25 08:51 -0800
  Re: "from module import data; print(data)" vs "import module; print(module.data)" sohcahtoa82@gmail.com - 2016-02-25 12:00 -0800
    Re: "from module import data; print(data)" vs "import module; print(module.data)" Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-02-26 11:20 +1300
      Re: "from module import data; print(data)" vs "import module; print(module.data)" Ben Finney <ben+python@benfinney.id.au> - 2016-02-26 10:38 +1100
        Re: "from module import data; print(data)" vs "import module; print(module.data)" Steven D'Aprano <steve@pearwood.info> - 2016-02-26 11:40 +1100
          Re: "from module import data; print(data)" vs "import module; print(module.data)" Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-25 20:56 -0700
          Re: "from module import data; print(data)" vs "import module; print(module.data)" Chris Angelico <rosuav@gmail.com> - 2016-02-26 15:11 +1100
          Re: "from module import data; print(data)" vs "import module; print(module.data)" Ben Finney <ben+python@benfinney.id.au> - 2016-02-26 15:37 +1100

csiph-web