| Deutsch English Français Italiano |
|
<global-20240305194545@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Variable scope inside and outside functions
Date: 5 Mar 2024 18:46:31 GMT
Organization: Stefan Ram
Lines: 19
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <global-20240305194545@ram.dialup.fu-berlin.de>
References: <mailman.28.1709662411.3452.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de nCUIGylQ+CnBBxKg01k14Q/vFtsw6KckxZGy62qKTkV0Ip
Cancel-Lock: sha1:2hKRpiztogU/drhebX6DReaiDm8= sha256:cIjHekUOJEYstuxHJvdimDFEm3B5eMZL2WbzyYBMbVo=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
Jacob Kruger <jacob.kruger.work@gmail.com> wrote or quoted:
>l_servers = []
....
> global l_servers
>That should, in theory, mean that if I assign a value to that variable
>inside one of the functions, it should reflect globally?
Yes.
l =[ 1, 2, 3 ]
def f():
global l
l =[ 2, 3, 4 ]
f()
print( l )
# [2, 3, 4]