Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

There is no distinctly native American criminal class except Congress. -- Mark Twain


comp / comp.lang.python / Re: Use of statement 'global' in scripts.

SubjectAuthor
* Use of statement 'global' in scripts.Popov, Dmitry Yu
`* Re: Use of statement 'global' in scripts.Greg Ewing
 `- Re: Use of statement 'global' in scripts.Popov, Dmitry Yu

1
Subject: Use of statement 'global' in scripts.
From: Popov, Dmitry Yu
Newsgroups: comp.lang.python
Date: Wed, 8 May 2024 01:32 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: dpopov@anl.gov (Popov, Dmitry Yu)
Newsgroups: comp.lang.python
Subject: Use of statement 'global' in scripts.
Date: Wed, 8 May 2024 01:32:32 +0000
Lines: 14
Message-ID: <mailman.13.1715136872.3326.python-list@python.org>
References: <DM8PR09MB6360F1F237428AEC6310C000DBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de ZjlL9V8Jo15SscCJsCUwkwO4eKf9vkxMqTQTEl3yZ4tA==
Cancel-Lock: sha1:VOutmTU8Gh3MiPbKUooSalXHRXk= sha256:i8O0y+Hi4MCbjhko7GMoY1BcV+TG8MNH3yd0fDk7aN4=
Return-Path: <dpopov@anl.gov>
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=anl.gov header.i=@anl.gov header.b=HBb/jlmL;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.170
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.68; '*S*': 0.02; 'comments': 0.03;
'modules.': 0.09; 'received:namprd09.prod.outlook.com': 0.16;
'to:addr:python-list': 0.20; 'to:name:python-list@python.org':
0.24; 'wondering': 0.31; 'subject:Use': 0.32; 'suitable': 0.32;
"i'm": 0.33; 'there': 0.33; 'same': 0.34; 'running': 0.34;
'really': 0.37; 'this.': 0.37; 'way': 0.38; 'usa': 0.60; 'dear':
0.62; 'exactly': 0.68; 'living': 0.71; 'global': 0.73;
'charset:iso-8859-1': 0.73; 'popov': 0.84
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=VuB7rnIntCgucLuLbKRgZe+UewfoD9Axm38fVnKsEn5Ef7L8Ta2J3Evg6Sf6IvXzTp2qfVnxlLvY+tkALZKa1Di9jC2e7P9nwaA61TVu+/0aIJVH5DUhhideUmDtm5g9lF1DvmmM6u/SSiG3y8L8jdafkzlskhNyIyGzMDBdmyRV1oD6JWb5inyTk8LcGIDUIUnY/s6oY0Ocz34MTZgxR5d9MJ7jf705AExmeRRJjoDHfSjCJHSW20O7Yq78XwhFWazOvLUiqLzuRh4KMUOjOWyJqkp+BGyKIdBTv6rmX0ELSNgM9mLu8HMqXQH+JHZpEpCABrQBx3yZ/ye19VgORg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=fPE3RiBRB2iAH4/hnHm8whZ1Aaf1iI464ZjN9Fr5Fs0=;
b=cGn/wwKQzKjlSts5pcAijBjdSoIYhSzJNuPsbcUJPKycE64TUlZqc9v91f4vEe3/Vs5/QBcnTH0vlJ8Xo5JoNxC6xKxw78ToI12g9hpTC4Ygp7hDUsxvtpMltY7B3Lmrg0WJI7Gncd44Yf7/5RRZT0VBvBTdiggXskA1L7wVvyn2AdhdBhedqt14+JaKzHVO6anRH4X3r8nQWIbrpkpB39Vt5CtbpW3pPn7G5FBG+9sM1O1z4/ns5TPZv0V7SfhE4ntfsVXYaYnKzN0SzKgJ8vxx2q55tHcaguuf5QEIJoTE8dlOQvFlMnaVktxEz0xfkqfMbONjFakaH2uI8kYN4w==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=anl.gov; dmarc=pass action=none header.from=anl.gov; dkim=pass
header.d=anl.gov; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anl.gov; s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=fPE3RiBRB2iAH4/hnHm8whZ1Aaf1iI464ZjN9Fr5Fs0=;
b=HBb/jlmLm9JOz5KAFksIzpoYxD8wwQm5YItYcyG77NJ4DaYzmxQCA9nKO/ShLM1+NgArrth2iwiS/tmydm46ycJJeYaXsRd1LMFMNh80laQqXQF+QFMqT9Jjsbvb0UCLYOeUxncR1A4MoRdxjDLMjbXLXaCocLKHH1cwRwD3SVLb62tY3r6zCPW6ghG/CwdIWu/nWkhP+1YDm/EQjM4MYNbnuzo+FFHPik4FWNnQzEOQudeqE9NHCRvB5n6huw2u+Exv4I92/Fy2yf7jR9hyfttDrxBa9Zi40lKQdYOwcDgriYolk5nIa/DoN2VgIBibGVg2bW83+VdIRjjYfA32fQ==
Thread-Topic: Use of statement 'global' in scripts.
Thread-Index: AQHaoOESfk9d0IV3VESInHGd3Ph4pw==
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=anl.gov;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: DM8PR09MB6360:EE_|SJ0PR09MB9398:EE_
x-ms-office365-filtering-correlation-id: 903c69fc-0238-4bd8-6307-08dc6efebb97
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230031|366007|1800799015|38070700009;
x-microsoft-antispam-message-info: OLBHaRwJPBK12SxNtS8X6D0Z8m7/ICZYoSDhHh7gl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JXKBYvq8w
PM8Fq4bzpES9IajmzEzdVIIw+I5oH0aSCc2bLrQ6LkFr45O1O26UlHRMT7
6ZzrynGnI/quHCHTR4BhFF8L2pSMTBhmLPgWj4VcX9/HIRlW9+9iMY4p1Y
MFlQS2GJJK6FTzAthYD9gseI00V1CL4uNVBcblBytTM73bMX/V3h3qgtzG
kaZWz32QaUDWDpP1K9gHG0yFm1kaS604Mzlg5vSvNLPfJlpzrweWb4Ggbk
dxyquMHoHQOyert3OWtSo3fpu+zstifg==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:DM8PR09MB6360.namprd09.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230031)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: juTw+oRX0KJJhT4yxQ5yINKpiO2pc4pjm/2Zj2p+PPv0aUqmFvSNFpyzQ1
QkUzjAhwsypcNUw8xEyEQoAvp1qZoaK7uVbHbIYk0BpI7WZr/Kzy34jPwb
b701B4fW2r+vmtXk9lXemo6OqnUpsD0MoPVqVhZ+plTnX/iA+fPgYg7/Wo
mE5KeJZb0J/HBd0T/hrQF3f0xfGgdxjBMKM8Qow3rj88vXYpXW9X4kdaH+
PlqPEDJX626a9jJV5kuipnVcmnO4grAx9TQ1vpeRC7Rh8xh5lpRSoJ1iYy
fvbrOCQ9A0F7mn0V37tN0PKy/uWMLBMz1AVk6n/ijZLEgKNE7FukHdXRu6
nmXmnlCpNQQmSi5HQXpszpfQ9alVU5HKUIM7d0S49hMEP+Ce3vw/mBm1r1
/Ma+n9TGrA3zBC9cAp/OIPcC0MdNSdbeEJUlmM3JWXFKPPCCy1qWouihrI
fSaN4IUydfp7aarmEevEutFNUPt/KTn2hcNBi48hbaiqEpT9HOILFJBEzM
gD0Rlr/ad08iUL8Mnex/dWCtcZTGdZcXC2QTytIr1sstNFyS7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exchange-CrossTenant-AuthSource: DM8PR09MB6360.namprd09.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 903c69fc-0238-4bd8-6307-08dc6efebb97
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2024 01:32:32.7515 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 0cfca185-25f7-49e3-8ae7-704d5326e285
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR09MB9398
X-Mailman-Approved-At: Tue, 07 May 2024 22:54:30 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <DM8PR09MB6360F1F237428AEC6310C000DBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
View all headers

Dear Sirs.

The statement 'global', indicating variables living in the global scope, is very suitable to be used in modules. I'm wondering whether in scripts, running at the top-level invocation of the interpreter, statement 'global' is used exactly the same way as in modules? If there are any differences, I would really appreciate any comments on this.

Regards,
Dmitry Popov

Lemont, IL
USA

Subject: Re: Use of statement 'global' in scripts.
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Wed, 8 May 2024 08:56 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: Use of statement 'global' in scripts.
Date: Wed, 8 May 2024 20:56:00 +1200
Lines: 24
Message-ID: <la0t13F1s8iU1@mid.individual.net>
References: <DM8PR09MB6360F1F237428AEC6310C000DBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
<mailman.13.1715136872.3326.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net dXqQgxcKZgQkkfZcURSt1wA+N/mEcrjV1p4dkA/40ZAALifLlf
Cancel-Lock: sha1:VfUF/kl1qJZc5oG+aDX7yP9DmJY= sha256:S9SvuqbbgegAaHu0PIyi+zwqSq7GRifhJmWMAlc1zeE=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <mailman.13.1715136872.3326.python-list@python.org>
View all headers

On 8/05/24 1:32 pm, Popov, Dmitry Yu wrote:
> The statement 'global', indicating variables living in the global scope, is very suitable to be used in modules. I'm wondering whether in scripts, running at the top-level invocation of the interpreter, statement 'global' is used exactly the same way as in modules?

The 'global' statement declares a name to be module-level, so there's no
reason to use it at the top level of either a script or a module, since
everything there is module-level anyway.

You only need it if you want to assign to a module-level name from
within a function, e.g.

spam = 17

def f():
global spam
spam = 42

f()
# spam is now 42

A script is a module, so everything that applies to modules also
applies to scripts.

--
Greg

Subject: Re: Use of statement 'global' in scripts.
From: Popov, Dmitry Yu
Newsgroups: comp.lang.python
Date: Wed, 8 May 2024 18:52 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: dpopov@anl.gov (Popov, Dmitry Yu)
Newsgroups: comp.lang.python
Subject: Re: Use of statement 'global' in scripts.
Date: Wed, 8 May 2024 18:52:57 +0000
Lines: 30
Message-ID: <mailman.0.1715194381.2806.python-list@python.org>
References: <DM8PR09MB6360F1F237428AEC6310C000DBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
<mailman.13.1715136872.3326.python-list@python.org>
<la0t13F1s8iU1@mid.individual.net>
<DM8PR09MB6360A831D8BB9936CC142EAADBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
X-Trace: news.uni-berlin.de vCZHaJChOvRvhDT6NIL8fAuuUtCYvlsqzGoFWSW06brw==
Cancel-Lock: sha1:/a9BYExFaDJ3U5syvnrnZvg0k+4= sha256:iJwLIuz4yxp7xwVh/L5Sfj+CYMs6I892Nb3UYVaq+n0=
Return-Path: <dpopov@anl.gov>
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=anl.gov header.i=@anl.gov header.b=n+oHtuE2;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.142
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.72; '*S*': 0.00; 'def': 0.04; 'e.g.': 0.07;
'modules': 0.07; 'scripts.': 0.07; 'modules.': 0.09; 'skip:z 20':
0.09; '&gt;': 0.14; 'url:mailman': 0.15; '2024': 0.16; '3:56':
0.16; 'anyway.': 0.16; 'applies': 0.16; 'greg': 0.16;
'received:namprd09.prod.outlook.com': 0.16; 'url-ip:3.215/16':
0.16; 'url:urldefense': 0.16; 'url:v3': 0.16; 'wrote:': 0.16;
'pm,': 0.19; 'to:addr:python-list': 0.20; 'to:name:python-
list@python.org': 0.24; 'url:listinfo': 0.25; 'wednesday,': 0.26;
'email addr:python.org&gt;': 0.28; 'dir="ltr"': 0.31; 'wondering':
0.31; 'python-list': 0.32; 'subject:Use': 0.32; 'suitable': 0.32;
"i'm": 0.33; 'there': 0.33; 'script': 0.33; 'same': 0.34; 'header
:In-Reply-To:1': 0.34; 'running': 0.34; 'skip:_ 30': 0.37; 'way':
0.38; 'use': 0.39; 'want': 0.40; 'skip:b 30': 0.61; 'skip:o 10':
0.61; "there's": 0.61; 'from:': 0.62; 'to:': 0.62; 'skip:i 20':
0.62; 'skip:b 20': 0.63; 'skip:m 20': 0.63; 'everything': 0.63;
'skip:b 10': 0.63; 're:': 0.64; 'your': 0.64; 'top': 0.65; 'came':
0.65; 'spam': 0.65; 'skip:t 20': 0.66; 'outside': 0.67; 'url-
ip:18/8': 0.67; 'url-ip:3/8': 0.67; 'exactly': 0.68; 'skip:# 10':
0.68; 'url:us': 0.69; 'within': 0.69; 'living': 0.71; 'skip:f 30':
0.71; 'global': 0.73; 'skip:f 20': 0.75; 'sent:': 0.78; '16px':
0.84; 'email name:&lt;python-list': 0.84; 'skip:& 50': 0.84;
'8px': 0.91
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=jv0RUJ2z9xqFcDWikxgMmsoIPIRZsRMQR+1B95Dm9yNHnaJ0UVRN5H011Q6T/Izi3jQulW9Hygh4WG9YirDvyEBdeA+SGk25trdUGA4cM0irOu6/abcTq7HpC7w9sAn7UWo1MgSqytKm5gCZwT2gE57/DVBkmimIAqY92gtmCrYXHW39Gylew09YJkggSnxrqimT95FJ8LEUHf7fVVUuTZQHFPOZmMWDSMDujOiOcX0612vOaC/ZyxVyUmg/AASkLE877Oq+0Re5nIcHqEpg0sf8/dDHUXOpEWlx+vn/doiN8+HNRHPIWT/hTm2VrNfyjrppSYKl7m3qBTnzqjmchg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=L4yYCSeTQMRGbb90kW3IAEYaZBqf/H0Xjp+3VlGO60E=;
b=nmIYcxXyW3Ze/Kb7gM4m5V7PC7ZAIhfbfrfdwSVsZIx04PsjOd9gTzz96IcP5c/LDhYt6Nf5J3PithiYiAtP4YBd0JVekRTtd95cj+1rLsCy1emOCEeTonS1IFGbeHhse8U9wQCBY/9MXGJECWxtV+B/XvQhOFW5vcIYPVlbe5snJT4/PTMSo/i+YSG3RrrPm0F8dA9oBekwno8lGuPcaLGfkoMDXi85mqh/sQ9FMyPZXiNq1xJWGY0jt7OLpCqimNn4bO2BaEYa36QrwJG4tm/ch4aAVeyK9vGpu3bBPlvkjlLx1zcnw/Q29NoIkVGZeC8cat87jOZZWzEga/bs2g==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=anl.gov; dmarc=pass action=none header.from=anl.gov; dkim=pass
header.d=anl.gov; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anl.gov; s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=L4yYCSeTQMRGbb90kW3IAEYaZBqf/H0Xjp+3VlGO60E=;
b=n+oHtuE2wZNE6by52CHQGiLPw00mdqrRX0KFcaPbYbDpGjllQfRuvMrjsWO+Sxf5JZqg6lu/PWC5LtOtEt1Phv3HA0nxuRLwD4N+k7MpSmGltpBPYoY0SQsyCZaHeU0QmZIIqIbnZLameHRoLSAuuELJpvYU7XnJio3lcgymFhkpxZsJzBg0OjhvP1FHRdi3y5UOzMTa5Q5PKOpGxriLyvp5+V4lF9b2Tu6DvJ/UXdsv1hmldnFIuruREcZO3Gy8iawh4iOvIf6InGC9Zkt4rL+VlqyU43cJ23NA1NHDaj/71upQqtDH1Ss6Z/PK/6wuXfbGkqK+z8bH4rHPHH2LxQ==
Thread-Topic: Use of statement 'global' in scripts.
Thread-Index: AQHaoOESfk9d0IV3VESInHGd3Ph4p7GNC06dgACkx+Q=
In-Reply-To: <la0t13F1s8iU1@mid.individual.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=anl.gov;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: DM8PR09MB6360:EE_|SA1PR09MB10692:EE_
x-ms-office365-filtering-correlation-id: e2f34e3a-6d5b-4535-96a6-08dc6f9013db
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230031|1800799015|366007|38070700009;
x-microsoft-antispam-message-info: pn7kmo6/I6WdMWqpr0MNUfdVP9gLK7n9HZl9JjYjrABpy
9HqoQAKIKJiB13xPV71MAtHDqgtiQ4H7ZAAhz8jI5LW+l
9qrSO1EHChqubw8NN/7mVM0I9+VOJIFNWG8ZSPtocBELh
FreYXU31RY4AKsZceO8LSJX6qh69qoheGryybGMvx4T4M
JAT5+OZXSjP5uXZi4HqveOaHSR2qtT/apoWzvDXVllOz+
pqm8t+NiJ25mb2kkm5D3WlqmyhQ3nSPTEgVEujhVrN/VY
YipuqngObYWbXZhfLLMLUM4oeOMpsMxJHVtf8JrAxqCbF
SqCkDvhPCvdNF3HdDBQ+ufyI+mvQrAtoKqqxKwpTLUb0B
Yh3WOwgaQ502YvA04Wjp6LIIW8XwWQuEReYO4b9PaNbip
XtPQsT4OVkrOBpc2XV2k/uzn7qftG9VUwLTlZJDm+PVx/
g1bVTs/ztEmA1RZlbrwYBL0Hu399gP9ruRN4nsgs3eFXb
0FRR+og6HT4yIIofuJ2AKWj2ctlgK03h8sgrbYSBbl0f7
L+0LWwxf/B8MCdgASyTErKRlYKYo8v9Nfn6jW6jT3kCfq
P6DNKuWqt/ODyPGRE6RoJu7OZQ3kWzC9QndSbKbuMKqo6
jxmNjbxKYpO/r7mFsyaaawJT+vKNT64KK0J5JAp941bI4
tTk2ewitKwjsM/nKnDiMiLerEqdcnLef0KOgw11ZaE3Dg
OJSJH/vwwMnQl+Zm/0Fd2kE3xMrfssYVlUaJ2aRVFZ4pV
82Zl8rxfuswPxAeYNEZ3808y0nyjqondaEX/0qB5h6Jd9
+c/M8wcgH4poi41TlYGIpRJ+M00D9Jq1X3N6rxRE9y1xV
SpENl2qgSm5h3U3xJorgOoXDMmscxPHKOwwXGzTIkXLL5
HrDrSVo27mN6vr2pIczueecdg8O934gipOIb+WwK4jQ5v
IWQTK1ruAC0/kGMMqamEpbKzID0/HLdORwKS4yeRGKMwY
dbGcQRgDGempawRBKAGG/XeSvT1B21RsmQVbwj2hslYPq
2HPJfyd67r1Lb+lO9ZNuRBexrMrnN2Dp4QpWVq+MmK3TI
/TR/oW/LlZA3o/evUTXPh+blNWProDm0TethCJA33kV/l
16RlbQAy796/XabG+TltfCTLDFGMcuVltlbLQbAPvJr59
2+qh7ihjS/niTnogz/OEw7h4IqKnvMJQZPFRxWuNKSQkf
Vw3zhWzWm4FNYcPJEWAJ0yB3hMsQNJkt4Wn1uuFqqrCQe
7A1VAoRlX2j++v7ctrtImGQHlRwfT9SXaOKSlwWKUA==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:DM8PR09MB6360.namprd09.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230031)(1800799015)(366007)(38070700009); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: X7RPlx4HIYe2jWrhjs/cA974ctJb1JlVFqPEhUwPuHyTe
IYPQamnmO5NNJyUa4ZvKtURItWMyGSoPqQRyEDtSEOkth
GUVxcEqFipP6n5vQsqlK/ye+erBROy90GuESRIEQXpxYl
mpi5O1FwRZPYaxqzY407FmAn2TblLTjKf9FmxfAdWWTwx
dlpJodS37UYAIzn8e2KoDL+AWrmQm/LxXuUjLlyQ1oUIt
bFOWt/jgB/JbTs/H5v2srXxq3SqXXzDUsBPDKxaJCECSD
XQymEPyhe/WtpIk6+C4g8pIJpVqCn1gS0RuBVVP4egk2t
KwEx4pFHPDZKo0sJY9FwF21NX22G+gGrwuzxFDN2UGaAh
7JE7dKSZXhRHASqEKdvIiy2s/f3lLbJeH76SI8VdGSPJD
c9mEi2Xlxx3wBHwAWvmqp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mkPcZOwuReDCHP
tdTDcsWVHRmnbGIWNZZbIQFOBHeOBnQ30lJiWVwKlh48+
UU7xnTpvdIE5scH0YG5AdXyXmdV/iCyOktZqUsybc6UMG
MDvY=
X-OriginatorOrg: anl.gov
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM8PR09MB6360.namprd09.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: e2f34e3a-6d5b-4535-96a6-08dc6f9013db
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2024 18:52:57.8494 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 0cfca185-25f7-49e3-8ae7-704d5326e285
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR09MB10692
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <DM8PR09MB6360A831D8BB9936CC142EAADBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
X-Mailman-Original-References: <DM8PR09MB6360F1F237428AEC6310C000DBE52@DM8PR09MB6360.namprd09.prod.outlook.com>
<mailman.13.1715136872.3326.python-list@python.org>
<la0t13F1s8iU1@mid.individual.net>
View all headers

Thank you!
________________________________
From: Python-list <python-list-bounces+dpopov=anl.gov@python.org> on behalf of Greg Ewing via Python-list <python-list@python.org>
Sent: Wednesday, May 8, 2024 3:56 AM
To: python-list@python.org <python-list@python.org>
Subject: Re: Use of statement 'global' in scripts.
On 8/05/24 1: 32 pm, Popov, Dmitry Yu wrote: > The statement 'global', indicating variables living in the global scope, is very suitable to be used in modules. I'm wondering whether in scripts, running at the top-level invocation of the interpreter,
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
On 8/05/24 1:32 pm, Popov, Dmitry Yu wrote:
> The statement 'global', indicating variables living in the global scope, is very suitable to be used in modules. I'm wondering whether in scripts, running at the top-level invocation of the interpreter, statement 'global' is used exactly the same way as in modules?
The 'global' statement declares a name to be module-level, so there's no
reason to use it at the top level of either a script or a module, since
everything there is module-level anyway.
You only need it if you want to assign to a module-level name from
within a function, e.g.
spam = 17
def f():
global spam
spam = 42
f()
# spam is now 42
A script is a module, so everything that applies to modules also
applies to scripts.
--
Greg
--
https://urldefense.us/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!G_uCfscf7eWS!airWCCS1QeLAhk0AfN3VxhuV9MZkx80000YBhs5Vjf89K2WZPjhCUkXt9culFzwlX1_ON0G17lukcR79-kWAsA$

1

rocksolid light 0.9.8
clearnet tor