Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

A woman should have compassion. -- Kirk, "Catspaw", stardate 3018.2


devel / comp.lang.python / Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

SubjectAuthor
o Re: Variable scope inside and outside functions - global statement being overridEthan Furman

1
Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

<mailman.51.1709744265.3452.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=29601&group=comp.lang.python#29601

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ethan@stoneleaf.us (Ethan Furman)
Newsgroups: comp.lang.python
Subject: Re: Variable scope inside and outside functions - global statement
being overridden by assignation unless preceded by reference
Date: Wed, 6 Mar 2024 08:57:27 -0800
Lines: 17
Message-ID: <mailman.51.1709744265.3452.python-list@python.org>
References: <aff560df-2f57-47d9-ad81-74c21960c21d@gmail.com>
<0ccad7a9-eaba-48e6-b972-d89e5a930c11@DancesWithMice.info>
<db322a1b-2d29-4b67-9d5c-3e8d8737c0f5@gmail.com>
<2248adf8-551f-4e86-8de8-be892d5978ed@tompassin.net>
<9c71abb0-b28d-4646-b130-9a4fdd529428@gmail.com>
<3d941cc0-2379-4771-e60c-5e14f31001fa@stoneleaf.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de N/RMN2tMbd6kJ+esC3P8UQ4zPz87aVc46Vg/y8Z39L5Q==
Cancel-Lock: sha1:3J0NXJmMi5Aab6NGCycwwMyfjOg= sha256:dBqKQAhduMvZd0ivVa/QyaBjnx1urSYMys++HlV9PZk=
Return-Path: <ethan@stoneleaf.us>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=stoneleaf.us header.i=@stoneleaf.us header.b=FfwVZqYy;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:217.70': 0.09;
'received:217.70.178': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; 'skip:` 20': 0.09; 'import':
0.15; 'that.': 0.15; 'from:addr:ethan': 0.16;
'from:addr:stoneleaf.us': 0.16; 'from:name:ethan furman': 0.16;
'message-id:@stoneleaf.us': 0.16; 'sorry.': 0.16; 'subject:being':
0.16; 'subject:reference': 0.16; '~ethan~': 0.16; 'wrote:': 0.16;
'python': 0.16; 'to:addr:python-list': 0.20; 'python,': 0.25;
'bit': 0.27; '>>>': 0.28; 'header:User-Agent:1': 0.30; 'dec':
0.31; 'module': 0.31; 'python-list': 0.32; 'but': 0.32; 'there':
0.33; 'header:In-Reply-To:1': 0.34; "couldn't": 0.40; 'becomes':
0.64; 'received:217': 0.67; 'and,': 0.69; 'subject: \n ': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stoneleaf.us;
s=gm1; t=1709744250;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=xrk/Nv4AhU5o8dBakDoNe9e4wF9a3UHM7EC2brKuCCg=;
b=FfwVZqYypSbZgioNfaDDBHZyu7t9AbO7BKNArhs5yA9AaImMFzBOxslv0rF13PKkMakN1+
OVqttLjwy63XTCT8dVOYM+WriLe4UiKMlZ0o8pee9xXPFR72HkN+HWVM9Uys2QuUmTxqvM
FTdGepGOnz4p0rrhIJqmWdzJ+cNobvdoWy072KqTUbXYXnH5Zr8YLVZ37kqrQAaK8XN2HZ
tCu4o/63aXGycAFXIFMbrZ11/kufVQEkJslvyGDp6eroWqlfZVZl/3M2usUSh0kttT6vWa
pyEIY1QMb+6cKEXabTlJIek4D+6vCcKTgLa53e1RUxH3E/gwhCjwv3y0MJq/gA==
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <9c71abb0-b28d-4646-b130-9a4fdd529428@gmail.com>
X-GND-Sasl: ethan@stoneleaf.us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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: <3d941cc0-2379-4771-e60c-5e14f31001fa@stoneleaf.us>
X-Mailman-Original-References: <aff560df-2f57-47d9-ad81-74c21960c21d@gmail.com>
<0ccad7a9-eaba-48e6-b972-d89e5a930c11@DancesWithMice.info>
<db322a1b-2d29-4b67-9d5c-3e8d8737c0f5@gmail.com>
<2248adf8-551f-4e86-8de8-be892d5978ed@tompassin.net>
<9c71abb0-b28d-4646-b130-9a4fdd529428@gmail.com>
 by: Ethan Furman - Wed, 6 Mar 2024 16:57 UTC

On 3/6/24 08:28, Jacob Kruger via Python-list wrote:

> C:\temp\py_try>python
> Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from scoping2 import *

And it becomes clear: only do `from ... import *` when the module has been specifically designed to support that.

If you were to also do `import scoping2` and, after calling `do_it()`, `print(scoping2.dt_expiry)`, you would see that
it had changed.

I know there are good explanations for how variables and names work in Python, but I couldn't find any at the moment.
Sorry.

--
~Ethan~

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor