Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If Bill Gates is the Devil then Linus Torvalds must be the Messiah. -- Unknown source


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 overridChris Angelico

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Variable scope inside and outside functions - global statement
being overridden by assignation unless preceded by reference
Date: Sat, 9 Mar 2024 08:30:53 +1100
Lines: 34
Message-ID: <mailman.72.1709933467.3452.python-list@python.org>
References: <bd2e0672-fc3e-4678-b212-04ab1f45c52c@gmail.com>
<ZepEKCbZNelFasml@cskk.homeip.net> <4Trnb856LRznVF4@mail.python.org>
<CAPTjJmqg4AwHpMLZqteK-qiRZwzDoUCLAFvYGku1X4H2f6b_RA@mail.gmail.com>
<4TrsPL1jK7znV1q@mail.python.org>
<CAPTjJmoZ_g8zhdkMhUteAMvT_7aJyWL6496yW65vxN-9CQ6eEw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 3c0+XjuYlfNw01C/Enf1QwNAQRieKd3fqDeSyG8HgC8A==
Cancel-Lock: sha1:jiWEkAQTzOIVQmzUzU5qRGCefH8= sha256:di7B0CUfQSCphcrvnKLDSi3ZNUCFuBZC82x4tZQ8+Vw=
Return-Path: <rosuav@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=eueQwj6j;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.012
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'mar': 0.07; 'space,':
0.07; 'angelico': 0.09; 'anyway,': 0.09; 'binding': 0.09; 'cc:addr
:python-list': 0.09; 'cc:no real name:2**0': 0.14; '"import':
0.16; '2024': 0.16; 'bindings': 0.16; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'means.': 0.16; 'question,': 0.16; 'script,': 0.16;
'subject:being': 0.16; 'subject:reference': 0.16; 'wrote:': 0.16;
'grant': 0.17; 'probably': 0.17; "aren't": 0.19; 'name.': 0.19;
'cc:addr:python.org': 0.20; 'sat,': 0.22; 'cc:2**0': 0.25;
"isn't": 0.27; 'else': 0.27; 'bit': 0.27; 'chris': 0.28; 'sense':
0.28; 'example,': 0.28; 'computer': 0.29; 'program': 0.31;
"doesn't": 0.32; 'concept': 0.32; 'python-list': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'there': 0.33; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'running': 0.34; 'from:addr:gmail.com': 0.35; 'people': 0.36;
'source': 0.36; "it's": 0.37; 'single': 0.39; 'use': 0.39;
'learn': 0.40; 'limited': 0.62; 'top': 0.65; 'entire': 0.67;
'exactly': 0.68; 'within': 0.69; 'too.': 0.70; 'global': 0.73;
'deal': 0.73; 'bias': 0.76; 'choice': 0.76; 'left': 0.83;
'global.': 0.84; 'scope': 0.84; 'spans': 0.84; 'subject: \n ':
0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1709933464; x=1710538264; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=idjscse69beaIrn9sXSA5Gi49XxSGhuTdzeCMb7GzLI=;
b=eueQwj6jDaQZEHMLZ4Ixb2e9mKsSWv5kxItKKhbR61EAoR+Gc19GogJ01yopKDw3DR
iqyS7BFs6wk2H+plI5VxTNRe3PZgUbfhoynS1jKErZ2Ho2UnyoZepMvpRXI/JPIzZIgc
yUuRx0bJwuj6nEW+8rgXYk1Fhn9SrNU0Q4GNyf75FvOhIYezpeGY0WOmxBpDOx7Y+PCe
sG+OgZfCyrKnKQAAcuLh047FXA3xGTpwiDrYcKV1sYO8kc7EeNdB8UlSo3kSw8TG5g/G
cp8L+RQxSkR2D3J+Z6NmjyoOMBizlnGWL6bZDZkCy0bWiGoDC9pBdV0thqAe4AhWGNiz
JXCg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1709933464; x=1710538264;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=idjscse69beaIrn9sXSA5Gi49XxSGhuTdzeCMb7GzLI=;
b=MxScouDBnZ0+N1MgK5Pxu71NK7tWO8/FlGJdcYbyDc5HqJsLHRszuGmuuplT/KtVEf
KSj05nY1hnQ1/y9QdGCs0FrUFHiR2pms+MY4mwNLVSTMMYzDQnhqFxVgLui4RdijTG+8
mGg+cccJKGpxdR57HxzyFNordDFu0fxZR2UirYNirgp5dHtjlD+Kc7wX3tHBFB0KjwlQ
Vi8KnQCI1LNAHL1wjmIyiio7fdtjE+5GrR3dDQ/2B8y3vnDwD7AaADSv6RFaC2AcEckp
mcp5kbCN2vpU9cPPJuXsHKGpa1BA61+UY5DXCPYuMQ2lqyydnWTIn3afwW8AyITAia5w
TaFQ==
X-Gm-Message-State: AOJu0YxfhQnwwrh4RSfIXAYsws9D1ruEmLoqJ+BhXGgxZCMLczXBCAMu
1vSLkAIQKTreb+iiNZYT1u8TyWi9xuAnlBBjHQEg9vgpKdbk2sJ4sYeVHELmVUm2ZsWUTTVDNRh
oF3FQU3+rLYiO1jnEEeJZWzmcI8/+649E
X-Google-Smtp-Source: AGHT+IGQOUIe54OJfyMi6gKJ5noGMFFWMOCh0+JNyODnBXbcMGl8i5AwyagcXi8hFZ5ea1Qvucn/sZFifVl5OumPZww=
X-Received: by 2002:a2e:a454:0:b0:2d2:4783:872a with SMTP id
v20-20020a2ea454000000b002d24783872amr241750ljn.29.1709933464488; Fri, 08 Mar
2024 13:31:04 -0800 (PST)
In-Reply-To: <4TrsPL1jK7znV1q@mail.python.org>
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: <CAPTjJmoZ_g8zhdkMhUteAMvT_7aJyWL6496yW65vxN-9CQ6eEw@mail.gmail.com>
X-Mailman-Original-References: <bd2e0672-fc3e-4678-b212-04ab1f45c52c@gmail.com>
<ZepEKCbZNelFasml@cskk.homeip.net> <4Trnb856LRznVF4@mail.python.org>
<CAPTjJmqg4AwHpMLZqteK-qiRZwzDoUCLAFvYGku1X4H2f6b_RA@mail.gmail.com>
<4TrsPL1jK7znV1q@mail.python.org>
 by: Chris Angelico - Fri, 8 Mar 2024 21:30 UTC

On Sat, 9 Mar 2024 at 03:42, Grant Edwards via Python-list
<python-list@python.org> wrote:
>
> On 2024-03-08, Chris Angelico via Python-list <python-list@python.org> wrote:
> > On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list
> ><python-list@python.org> wrote:
> >
> >> One might argue that "global" isn't a good choice for what to call the
> >> scope in question, since it's not global. It's limited to that source
> >> file. It doesn't make sense to me to call a binding "global", when
> >> there can be multile different "global" bindings of the same name.
> >
> > Most "globals" aren't global either, since you can have different
> > globals in different running applications.
>
> To me, "global" has always been limited to within a single
> process/address space, but that's probably just bias left over from
> C/Pascal/FORTRAN/assembly/etc. It never occurred to me that a global
> called "X" in one program on one computer would be the same as a
> global called "X" in a different program on a different computer
> somewhere else on the "globe".
>

Yeah. My point is, though, the name "global" is a bit of a hack
anyway, so it's not THAT big a deal if it has other caveats too. For
example, let's say you always "import globals" at the top of every
script, and then assign "globals.x = 123" etc. Now you have a concept
of globals that spans the entire application, right? Well, no, not if
you use multiprocessing.

So, go ahead and call them globals, but people will always have to
learn about exactly what that means.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor