Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"One day I woke up and discovered that I was in love with tripe." -- Tom Anderson


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 overridJacob Kruger

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: jacob.kruger.work@gmail.com (Jacob Kruger)
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 19:29:12 +0200
Lines: 31
Message-ID: <mailman.52.1709746162.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>
<fa206b90-8298-4e8d-8dd6-a73066dfacfd@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de FL3hykiVMuYI6/9s1S99xQgumL23FHivRfQP59aWrO4Q==
Cancel-Lock: sha1:/IhnmawUNQePKAYqaLeWs1bOgvk= sha256:o4tPR91aM9pA+26n2+BQRlhb0eAex713rbyU0nHQulg=
Return-Path: <jacob.kruger.work@gmail.com>
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=gmail.com header.i=@gmail.com header.b=cMdKLoEq;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.019
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'modules': 0.07; 'ok,':
0.09; 'skip:` 20': 0.09; 'import': 0.15; 'that.': 0.15; 'ethan':
0.16; 'sorry.': 0.16; 'subject:being': 0.16; 'subject:reference':
0.16; '~ethan~': 0.16; 'wrote:': 0.16; 'python': 0.16; 'instead':
0.17; 'message-id:@gmail.com': 0.18; 'to:addr:python-list': 0.20;
'python,': 0.25; 'bit': 0.27; '>>>': 0.28; 'sense': 0.28; 'header
:User-Agent:1': 0.30; 'code,': 0.31; 'module': 0.31; 'python-
list': 0.32; 'received:192.168.1': 0.32; 'but': 0.32; 'there':
0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'thanks,': 0.36; 'received:192.168':
0.37; "couldn't": 0.40; 'should': 0.40; 'becomes': 0.64;
'generally': 0.67; 'and,': 0.69; 'operate': 0.75; 'skip:f 20':
0.75; 'etc.,': 0.84; 'subject: \n ': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1709746160; x=1710350960; darn=python.org;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id:from
:to:cc:subject:date:message-id:reply-to;
bh=gr/RsAWBn2zrVpN8h2pNv8cJdOdxJ1161lb+473aWqY=;
b=cMdKLoEqUj2SZvbeyhOSFmSkBHIMurlFb3vAasdFxk+UreTUPsDwooZ2CuI5j++tiK
7KKT5z5yZ0uofBkahFOlP55uzAYi/7NzDTpt0ba8kPlnMGxYWVddtjG6FyYlPr0wM+ai
umpLLblZHnlF2LKqWlcW8tBJd9D4JlIvlXcSEF0quWmDWWoPCX8V5lhrW1WXgPe8woap
YjgZln+Lxcfhr1cz/ybad1oTQhWwHP9hgExT7Vos7ojq5Elj8o9BZwUV9L3wUdKcH/Ys
JTRKewGHo/1AHNy6QLeS/vIHJkVxMuWOAmlb/7YVaGEY0ZYLT6UDrOH06jtlQWuCFk6m
aaKA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1709746160; x=1710350960;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=gr/RsAWBn2zrVpN8h2pNv8cJdOdxJ1161lb+473aWqY=;
b=dZ5ye8bjfzUD64kAzNsdLTMkgHYZ+hqVFaqu/AVUc6YzsEDPrHkL9cmJ/2UTXSJLO1
gtjWrBPL8msIUeFKkKXc083jMTXvP/Q7+pvst/G5hwW4fcTGYFXfyCBFjvF9ygyOrzIK
wg+wA+RXVaSBMdh6DlnraT9v5G52JNmdnO62VQglfPPstwYEyqTEzJo2h4c5hLmtGntp
ek8WYEiKanLIZWTjXQ+sTSvw644n4AVOLB6D87cKDVorhDgWWXq1h3QR+U6XauX7Vtqu
0zQD7RhV6pPaTHug4tKh7EYpoCr4cuqXcbK6kd+5lgfO5lNXw9BAwGvEm3OsJJKSukeo
Xb8g==
X-Gm-Message-State: AOJu0YxyaAPGXmAaRqXNymnJHmcIZj/Wz6aphAOx/BZ2N7TeE89D0VuK
Hw6cb0t6gcpM7LO7ikzT+yt5AQBaN45GuFC0m3dVGpxx4QJERXO/F5nIvRy8
X-Google-Smtp-Source: AGHT+IFT+9LPFrlXbGZWNuk1pkTK3e45eKlmzSY3PdSmwVQpYLAZo3D/hPEzli1yYAKy29SVlraMMA==
X-Received: by 2002:a2e:95d9:0:b0:2d2:fb9f:f7e3 with SMTP id
y25-20020a2e95d9000000b002d2fb9ff7e3mr3517234ljh.50.1709746160210;
Wed, 06 Mar 2024 09:29:20 -0800 (PST)
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <3d941cc0-2379-4771-e60c-5e14f31001fa@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: <fa206b90-8298-4e8d-8dd6-a73066dfacfd@gmail.com>
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>
<3d941cc0-2379-4771-e60c-5e14f31001fa@stoneleaf.us>
 by: Jacob Kruger - Wed, 6 Mar 2024 17:29 UTC

Ok, Ethan, that makes sense - I generally work with modules in folders,
etc., but, this was just test code, but, 'see' if I instead import
scoping2 as sc2, and then refer to sc2.dt_expiry and sc2.do_it, then it
does operate as it should - thanks, again.

Jacob Kruger
+2782 413 4791
"Resistance is futile!...Acceptance is versatile..."

On 2024/03/06 18:57, Ethan Furman via Python-list wrote:
> 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.8
clearnet tor