Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

<sangr> home is where the highest bandwidth is


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 overridRoel Schroeven

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
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 16:55:39 +0100
Lines: 28
Message-ID: <mailman.47.1709740545.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>
<b42cb52d-a524-4a20-a4a6-4b04622052e0@roelschroeven.net>
<23ddcc43-7ab5-49ea-a188-8fc94e0a78c1@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de M6D47HkZbsIAkvY8jXtriwCwxTXVN/Eiz/10S5uhYI8g==
Cancel-Lock: sha1:FxyEjmRcbab2vDvHUIbY0zbn77o= sha256:Fa33nVrlOQcsFne4B4FYvYQFUN/gEs7TeyMhsBGtN60=
Return-Path: <roel@roelschroeven.net>
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=roelschroeven.net header.i=@roelschroeven.net
header.b=a4bIiLA1; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'likewise': 0.09; 'meant':
0.09; 'roel': 0.09; 'schroeven': 0.09; 'import': 0.15; '"import':
0.16; '"what': 0.16; 'confusion.': 0.16; 'executed': 0.16;
'expected.': 0.16; 'idle.': 0.16; 'ipython,': 0.16;
'received:10.202': 0.16; 'received:10.202.2': 0.16;
'received:10.202.2.163': 0.16; 'received:64.147': 0.16;
'received:64.147.123': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'rien': 0.16; 'schreef':
0.16; 'script,': 0.16; 'subject:being': 0.16; 'subject:reference':
0.16; 'want,': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20;
'maybe': 0.22; 'code': 0.23; 'seems': 0.26; 'it,': 0.29; 'header
:User-Agent:1': 0.30; 'whole': 0.30; '(as': 0.32; 'but': 0.32;
'same': 0.34; 'mean': 0.34; 'header:In-Reply-To:1': 0.34;
'people': 0.36; 'file': 0.38; 'way': 0.38; 'put': 0.38;
'8bit%:14': 0.38; 'something': 0.40; 'online': 0.63; 'key': 0.64;
'your': 0.64; 'saw': 0.65; 'received:64': 0.67; 'exactly': 0.68;
'plus': 0.73; 'non': 0.75; 'que': 0.84; 'code)': 0.84; 'mais':
0.84; 'soit': 0.84; 'subject: \n ': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to; s=fm3; t=1709740539; x=1709826939; bh=l/a+fx+o5jwqhPgr8DHNf
/MvztIGTWV8gnOZN+7yS7A=; b=a4bIiLA1DdpdVjGW1+1DCvzSijyV38Du1xKuL
NMz61AIi6AyIDwdfwloTP07gfQ7aegFoAz7m3aaPhD2u4y09Jexrs+sv+jZS8lyX
L7zljtoyuJqymk2RnTCyOTnKV8Aw9qsXrfECBXcvwxKH01t3G1uLLs703JYTWq4c
B63XkJliFQGfupvOiM3JZ9iOhCkr8uK2Xf3uP2OyVw7aa+/YxiYpOcehRjaVtFcU
AE2rO6cziimZPKp1vyLO2CzKpgKfE/p4rR3UwYNHQnIolkE58b1oOwfLKzR3vLjo
P6Hj8NrCYw5LI5k2Vlu4ES8J2tf/vouUJC3OQm0T8n5AhlcCw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy
:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1709740539; x=
1709826939; bh=l/a+fx+o5jwqhPgr8DHNf/MvztIGTWV8gnOZN+7yS7A=; b=L
O+620ugy2U/1qT3ApmL8pQarwMVkRQ2Je/vHqRTqR7DH+CtrFQfm0mlEtc1YioFa
aLUf4OhlxSYuqHQDOXl3gBTn7fStwpBy9C9P4QoHFt1a9Xeznvdzr5c/4SaUM1OQ
8Qqu42bXKzT8gsepIAzGTiU6okPWmPructRydn8FvJYxIPDMZmKta4OWLZcFga5D
BGF97bqNWwwScWJpMU1xLYLEoeKh31RAbchM1nfHMz7OuQ8Qkx/VRdK3e2Sjdz4F
Ysux7ocg3FVR4/a2Ah+JC2X1JfM/6MmFI2GMytm2qKOUKq5qSXnnlg0tx1W8Blni
V8zkFX8dSsU3MUB2hCZPg==
X-ME-Sender: <xms:-5HoZewvD0feld3OosZmFdfsehkYDcMJ-NgpMoQPrBYakag-r09ylQ>
<xme:-5HoZaSLCwS5tlHTmJ83jJTpIHo4tAw5_YroZ2wJxE2aWlxzcIqOGIvHRWy8Z28Cm
xq9jQXONWpm>
X-ME-Received: <xmr:-5HoZQUl8AKbXLH6Zxpem-FyPQztAJZokyKF-UXEU6U2D0ccmc-mMbKUKWOFTE-VvgYQs4KmMLIOVU4wthmxGrOq7HsywTDnFsLy_Pu2KsQrs-Y>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledriedugdejlecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekre
dttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghnuceorhhovghlsehrohgv
lhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrhhnpeelffdvueejteette
egudejveejvddvheefgeethedufeekfeffudelffeugfdvgfenucffohhmrghinhepthhi
ohdrrhhunhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh
hmpehrohgvlhesrhhovghlshgthhhrohgvvhgvnhdrnhgvth
X-ME-Proxy: <xmx:-5HoZUitAb2ZO3CgvIHPLeb9rj9RYrWH0vujDkEvHK7VNUoyxfSXdw>
<xmx:-5HoZQA8CWYel_FCWPrFFawkf6io_ymYwlldRJpnnaluDqAxJUSVBw>
<xmx:-5HoZVIovY6nirDfpYmMYwn-bnon7qGiBhhj2xV8478fBamZf9YrJw>
<xmx:-5HoZZ4Zlkaa6FEDEFX4qc78OuIkc3zTvhOqGHKfXzKWUfF0QtXAFSXXd6c>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: nl, en-US
In-Reply-To: <b42cb52d-a524-4a20-a4a6-4b04622052e0@roelschroeven.net>
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: <23ddcc43-7ab5-49ea-a188-8fc94e0a78c1@roelschroeven.net>
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>
<b42cb52d-a524-4a20-a4a6-4b04622052e0@roelschroeven.net>
 by: Roel Schroeven - Wed, 6 Mar 2024 15:55 UTC

Op 6/03/2024 om 16:39 schreef Roel Schroeven via Python-list:
> Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list:
>> If you import the contents of that file into the python interpreter,
>> [...]
>
> What exactly to you mean by "import the contents of that file into the
> python interpreter"? Other people have put your code in a script,
> executed it, and saw it working as expected. I pasted in IPython, and
> likewise saw it working as expected, and the same with IDLE. It seems
> to me you must be doing something different from us; maybe the way you
> execute that code might be the key to this whole confusion.
(As an aside, I made a type; "What exactly _do_ you mean" is what I
meant to type)

If you want, you can play with the code online here:
https://tio.run/##pVPbitswEH3XVwwJITaNQ9KllATy0EKhL/2AUsqiWKNkWlkykrzZ7NJvT0e@JWT7VmPsEZozc87RqD7Ho7MPl8sUQpQ@QukUCqG9q0DJiJEqBKpqx1vDegHp@@JsHyk0UfaY0tXnIT/FQogpkKVI0lBAcJ4OZKWBJ2kaDEKo@IjPNfkz7MYGyxB9nYJsst58XBWrNb@wWm1Xq8kCJrPvxawqZgpmX7ezb5N86bE2ssQsvpDVbjewWzaxzIUwjxFD5PI/1gt4v4CHn0xKoQblHilm@VYAPwfj9kxrpLOAHjcFGX6jgrp1CqIDjxp9CnrMk/Qk9wYDaOdh7@JRtCUTMtDBgsVTp5edYbuIZZpzl/NP@dadsvzdaG1WkW2Yy@5D3mJqTzZmIzK5pTu37p3JmcOvhkUw2XB0pxsmRxlgj2h7jqh6ygcv990pOg18ZLEV5bFo0ulpoIhVaHOTP1XNvFN21rmV91W0M8adyB64hEWoUNowGHoiY8CwVg/sp8coyQ722MHTwEWRCZYy9SVGMd9KWqqbBFWcGkgh6MaWkbgOryNKlSi2igdZV8kj6RCXpUHps4FtPz/X4QwYU6F@RlNSMoESv071digk6xqtymgoJVXXMdl027DP22xyvg8cpfLt/I0KRL@RLiDwhHanPP@M3Brn@bAu2mdc6/k4B7vXMfxzs98R2L12/@tOPrb48owlz1fH575TMTbsr8sb@CfNR3kH@x9@l8tf

(sorry for the long URL; that's where tio.run puts the code)

Again it works as expected, but with or without the l_test.clear() line.

--
"Il semble que la perfection soit atteinte non quand il n'y a plus rien à
ajouter, mais quand il n'y a plus rien à retrancher."
"Perfectie is niet bereikt als er niets meer toe te voegen is, maar als er
niets meer weg te nemen is."
-- Antoine de Saint-Exupéry

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor