Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

It is much easier to suggest solutions when you know nothing about the problem.


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 overridGrant Edwards

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

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

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=25422&group=comp.lang.python#25422

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: grant.b.edwards@gmail.com (Grant Edwards)
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 12:59:38 -0500 (EST)
Lines: 22
Message-ID: <mailman.54.1709747979.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>
<b0b253c4-5e9e-44a3-975a-11851009d52c@wichmann.us>
<cbaf27c2-d2cb-4de1-a1c0-02a9fc9bf252@gmail.com>
<2007e9a9-01e9-48fd-b060-56b9ac4db4c9@roelschroeven.net>
<4TqgDp5mGRznVGY@mail.python.org>
X-Trace: news.uni-berlin.de qvgmoGexUsDBIMzdSA8Kfw6zXg85qH9rjd4WbU1NBg2g==
Cancel-Lock: sha1:RfMPzpnkHiWykJjBnoS4Hmi9dwI= sha256:ASqpklmpXUvpZADwJjPD7qkR9DU+sF4/Tjn/CXlGoW0=
Return-Path: <grant.b.edwards@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'class.': 0.07; 'modules':
0.07; 'methods,': 0.09; 'roel': 0.09; 'schroeven': 0.09;
'tutorial': 0.12; 'import': 0.15; 'possible,': 0.15; "'import":
0.16; 'assuming': 0.16; 'directly,': 0.16;
'from:addr:grant.b.edwards': 0.16; 'from:name:grant edwards':
0.16; 'schreef': 0.16; 'subject:being': 0.16; 'subject:reference':
0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20;
'written': 0.22; 'code': 0.23; 'tutorials': 0.23; '(and': 0.25;
'>>>': 0.28; 'fact': 0.28; 'header:User-Agent:1': 0.30; 'python-
list': 0.32; 'but': 0.32; 'particular': 0.33;
'from:addr:gmail.com': 0.35; 'people': 0.36; 'this.': 0.37; 'way':
0.38; 'use': 0.39; 'learn': 0.40; 'between': 0.63; 'prevent':
0.67; 'message-id:invalid': 0.68; 'global': 0.73; 'keystrokes,':
0.84; 'saves': 0.84; 'subject: \n ': 0.84
User-Agent: slrn/1.0.3 (Linux)
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: <4TqgDp5mGRznVGY@mail.python.org>
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>
<b0b253c4-5e9e-44a3-975a-11851009d52c@wichmann.us>
<cbaf27c2-d2cb-4de1-a1c0-02a9fc9bf252@gmail.com>
<2007e9a9-01e9-48fd-b060-56b9ac4db4c9@roelschroeven.net>
 by: Grant Edwards - Wed, 6 Mar 2024 17:59 UTC

On 2024-03-06, Roel Schroeven via Python-list <python-list@python.org> wrote:
> Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list:
>> >>> from scoping2 import *
>
> [...]
>
> I would advice not to use 'import *', if at all possible, for multiple
> reasons, one of which is to prevent problems like this.

Unfortunately, many (most?) tutorials for particular modules (and even
example code in the Python documentation itself) are all written
assuming that you do "from <module> import *". It saves the tutorial
write a few keystrokes, but causes untold trouble for people who learn
incorrectly that "from <module> import *" is the proper way to do
things.

> I would also advice not to use global variables from other modules
> directly, and in fact would advice to minimize the use of globals in
> general as much as possible. If you need to keep state between
> methods, it might be better to use a class.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor