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


Groups > comp.lang.python > #109829

Re: the global keyword:

Path csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail
From MRAB <python@mrabarnett.plus.com>
Newsgroups comp.lang.python
Subject Re: the global keyword:
Date Sun, 12 Jun 2016 01:09:13 +0100
Lines 15
Message-ID <mailman.5.1465690157.2288.python-list@python.org> (permalink)
References <edb72d55-3a44-45f8-8122-b86d62e837c3@googlegroups.com> <1465689049.1080307.634938641.5F600BCB@webmail.messagingengine.com> <b2e32f44-d253-309d-dbd0-886bfcb7c7fa@mrabarnett.plus.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de xcfiB02xN/L1zlBEhj1aPQhSZ4THau3DrDKOyHRYGpkw==
Return-Path <python@mrabarnett.plus.com>
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; 'imported': 0.09; 'throw': 0.09; 'importing': 0.15; 'value.': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; "module's": 0.16; 'received:192.168.1.4': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'variable.': 0.16; 'wrote:': 0.16; 'refers': 0.18; 'creates': 0.18; 'variable': 0.18; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User- Agent:1': 0.26; "doesn't": 0.26; 'question': 0.27; 'module.': 0.27; 'reflected': 0.29; 'way?': 0.29; 'anyone': 0.32; 'source': 0.33; 'true.': 0.33; 'could': 0.35; 'possible': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'does': 0.39; 'subject:the': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; '(global': 0.84; 'test.py)': 0.84; 'subject::': 0.85
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=K//fZHiI c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=U1r_xPKvQ-m0OjPlDiwA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1
In-Reply-To <1465689049.1080307.634938641.5F600BCB@webmail.messagingengine.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <b2e32f44-d253-309d-dbd0-886bfcb7c7fa@mrabarnett.plus.com>
X-Mailman-Original-References <edb72d55-3a44-45f8-8122-b86d62e837c3@googlegroups.com> <1465689049.1080307.634938641.5F600BCB@webmail.messagingengine.com>
Xref csiph.com comp.lang.python:109829

Show key headers only | View raw


On 2016-06-12 00:50, Random832 wrote:
> On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote:
>> So my question is, how the heck is it possible that I get 5 as the last
>> value printed? the global test_var (global to Test.py) I set to 44 when I
>> ran some_function()???  does anyone have a clue they could throw my way?
>
> Importing a variable from a module copies its value into your own
> module's variable. Updates to the source module's variable will not be
> reflected in your module.
>
Not true. Importing doesn't copy the value.

Importing a name creates a new name in the local scope that refers to 
the same object that the imported name referred to.

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


Thread

the global keyword: Marcin Rak <mrak@sightlineinnovation.com> - 2016-06-11 16:44 -0700
  Re: the global keyword: Random832 <random832@fastmail.com> - 2016-06-11 19:50 -0400
    Re: the global keyword: Marcin Rak <mrak@sightlineinnovation.com> - 2016-06-11 17:12 -0700
      Re: the global keyword: Random832 <random832@fastmail.com> - 2016-06-11 21:27 -0400
    Re: the global keyword: Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-11 20:15 -0700
      Re: the global keyword: Random832 <random832@fastmail.com> - 2016-06-12 14:46 -0400
  Re: the global keyword: MRAB <python@mrabarnett.plus.com> - 2016-06-12 01:09 +0100
    Re: the global keyword: Marcin Rak <mrak@sightlineinnovation.com> - 2016-06-11 17:13 -0700
      Re: the global keyword: Ned Batchelder <ned@nedbatchelder.com> - 2016-06-11 20:41 -0700
  Re: the global keyword: Random832 <random832@fastmail.com> - 2016-06-11 21:26 -0400
    Re: the global keyword: Steven D'Aprano <steve@pearwood.info> - 2016-06-12 13:38 +1000
      Re: the global keyword: Ned Batchelder <ned@nedbatchelder.com> - 2016-06-11 20:48 -0700
        Re: the global keyword: Marcin Rak <mrak@sightlineinnovation.com> - 2016-06-12 11:31 -0700
  Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-12 20:07 +0100
    Re: the global keyword: Ned Batchelder <ned@nedbatchelder.com> - 2016-06-12 12:25 -0700
      Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-12 22:10 +0100
        Re: the global keyword: Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-06-19 16:35 +0200
          Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-19 22:20 +0100
            Re: the global keyword: Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-06-20 13:14 +0200
              Re: the global keyword: Steven D'Aprano <steve@pearwood.info> - 2016-06-20 22:15 +1000
                Re: the global keyword: Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-06-20 15:04 +0200
                Re: the global keyword: Random832 <random832@fastmail.com> - 2016-06-20 09:29 -0400
                Re: the global keyword: Steven D'Aprano <steve@pearwood.info> - 2016-06-21 00:53 +1000
                Re: the global keyword: Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-06-21 10:08 +0200
                Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-21 11:41 +0100
                Re: the global keyword: Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-06-21 13:01 +0200
        Re: the global keyword: Joel Goldstick <joel.goldstick@gmail.com> - 2016-06-19 13:16 -0400
          Re: the global keyword: Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-19 22:50 -0700
          Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-20 11:21 +0100
            Re: the global keyword: Steven D'Aprano <steve@pearwood.info> - 2016-06-20 22:03 +1000
    Re: the global keyword: Rick Johnson <rantingrickjohnson@gmail.com> - 2016-06-21 10:04 -0700
      Re: the global keyword: Random832 <random832@fastmail.com> - 2016-06-21 13:15 -0400
        Re: the global keyword: Rick Johnson <rantingrickjohnson@gmail.com> - 2016-06-21 15:20 -0700
          Re: the global keyword: Chris Angelico <rosuav@gmail.com> - 2016-06-22 08:32 +1000
            Re: the global keyword: Rick Johnson <rantingrickjohnson@gmail.com> - 2016-06-21 16:43 -0700
          Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-22 00:15 +0100
            Re: the global keyword: Rick Johnson <rantingrickjohnson@gmail.com> - 2016-06-21 17:24 -0700
              Re: the global keyword: BartC <bc@freeuk.com> - 2016-06-22 10:24 +0100
                Re: the global keyword: Steven D'Aprano <steve@pearwood.info> - 2016-06-24 11:00 +1000
                Re: the global keyword: Chris Angelico <rosuav@gmail.com> - 2016-06-24 11:19 +1000
                Re: the global keyword: eryk sun <eryksun@gmail.com> - 2016-06-24 02:19 +0000
          Re: the global keyword: Rick Johnson <rantingrickjohnson@gmail.com> - 2016-06-21 16:50 -0700

csiph-web