Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

A Fortran compiler is the hobgoblin of little minis.


devel / comp.lang.python / Re: Variable scope inside and outside functions

SubjectAuthor
* Re: Variable scope inside and outside functions - global statement being overridJacob Kruger
`- Re: Variable scope inside and outside functionsStefan Ram

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: jacob.kruger.work@gmail.com (Jacob Kruger)
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 18:28:59 +0200
Lines: 365
Message-ID: <mailman.48.1709742549.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>
<2248adf8-551f-4e86-8de8-be892d5978ed@tompassin.net>
<9c71abb0-b28d-4646-b130-9a4fdd529428@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de qZTMBjnav5AclmUr0XNnwA6CBtIQyVoR3rycitXGzcFg==
Cancel-Lock: sha1:VB9IAhIN4rSgZ1IR/aVAv7CBAPg= sha256:rKxXKqmKD3sJfVBaODLeLeAqgpl/OBb3HuIkAzo31HU=
Return-Path: <jacob.kruger.work@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=H7hJElcp;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'def': 0.04;
'variable': 0.05; 'interacting': 0.07; 'moment,': 0.07; 'child':
0.09; 'console,': 0.09; 'datetime': 0.09; 'itself,': 0.09;
'meant': 0.09; 'objects,': 0.09; 'ok,': 0.09; 'parse': 0.09;
'populate': 0.09; 'shift': 0.09; 'something,': 0.09; 'treated':
0.09; 'ultimate': 0.09; 'values.': 0.09; 'steps': 0.11; 'import':
0.15; 'problem.': 0.15; '>>>>': 0.16; 'behaviour': 0.16;
'confused': 0.16; 'confused,': 0.16; 'directly,': 0.16;
'executed': 0.16; 'functions,': 0.16; 'importing': 0.16;
'initiate': 0.16; 'interpreter': 0.16; 'iterable': 0.16;
'manipulating': 0.16; 'not)': 0.16; 'psutil': 0.16; 'purely':
0.16; 'received:mail-ej1-x635.google.com': 0.16; 'removes': 0.16;
'reproduce': 0.16; 'run,': 0.16; 'script.': 0.16; 'should,': 0.16;
'something.': 0.16; 'subject:being': 0.16; 'subject:reference':
0.16; 'syntax,': 0.16; 'timezone': 0.16; 'value?': 0.16;
'values,': 0.16; 'variable,': 0.16; 'variables,': 0.16; 'while,':
0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16; 'values':
0.17; 'code.': 0.17; 'instead': 0.17; 'message-id:@gmail.com':
0.18; 'figure': 0.19; 'reduce': 0.19; 'to:addr:python-list': 0.20;
'all,': 0.20; 'issue': 0.21; 'input': 0.21; "what's": 0.22;
'version': 0.23; 'code': 0.23; 'command': 0.23; 'lines': 0.23;
'skip:p 30': 0.23; 'run': 0.23; 'list,': 0.24; '(and': 0.25;
'anything': 0.25; 'actual': 0.25; 'seems': 0.26; 'interact': 0.26;
'object': 0.26; 'else': 0.27; 'local': 0.27; 'bit': 0.27;
'function': 0.27; '>>>': 0.28; 'expect': 0.28; 'output': 0.28;
'sense': 0.28; 'example,': 0.28; 'asked': 0.29; 'it,': 0.29;
'header:User-Agent:1': 0.30; 'seem': 0.31; 'am,': 0.31;
'wondering': 0.31; 'think': 0.32; "doesn't": 0.32; 'empty': 0.32;
'issues.': 0.32; 'python-list': 0.32; 'requests,': 0.32; 'same,':
0.32; 'specified': 0.32; 'words,': 0.32; "wouldn't": 0.32;
'exactly': 0.68; 'items': 0.68; 'matter': 0.68; 'revert': 0.68;
'during': 0.69; 'and,': 0.69; 'everything,': 0.69; 'following:':
0.69; 'relate': 0.69; 'types,': 0.69; 'within': 0.69; 'truly':
0.70; 'carry': 0.71; 'ignore': 0.71; 'longer': 0.71; 'content':
0.72; 'global': 0.73; 'little': 0.73; 'relevant': 0.73; 'causing':
0.75; 'name,': 0.75; 'skip:f 20': 0.75; '8bit%:100': 0.76; '....':
0.76; 'formatting': 0.76; 'successful': 0.78; 'moment': 0.81;
'extra': 0.84; 'bid': 0.84; 'executing': 0.84; 'experiment': 0.84;
'forgotten': 0.84; 'honestly,': 0.84; 'literally': 0.84;
'manipulated': 0.84; 'occurring': 0.84; 'referenced': 0.84;
'referral': 0.84; 'scope': 0.84; 'skip:% 30': 0.84; 'subject: \n
': 0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'skip:d 30':
0.86; 'down,': 0.91; 'retain': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1709742547; x=1710347347; darn=python.org;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id:from
:to:cc:subject:date:message-id:reply-to;
bh=LQ4ulc40tnz1bGB3wRC6MLEzpC/T+82cBXegozNmJF0=;
b=H7hJElcp7Bkrhxveb2ThqQ3Hhidiw+JWLfT+LuqiyHD0We/RPc6SvJ8EmAm2O6sUv/
qBhbCQUv1aereXvAQE1jLPuq9JWsfnOz+Hm3vxziT27icU4aWv7r+MBlMWqXJPGI+ih4
lJVvD0Ft5ixmxngm+MFNjvJd/I8S3OEOh5mnSckYwZJu4nQDrOoYYb5oyPCn7QivVoz0
MkTE9IlRmPbTizCw+6Krz1TFHOMiW/VThyhKIeQbTZfRYq+TmAoKiJ/KCZHktFdovtGq
bNq9/2ZyL73i/lvcEXFeYpbV0CpcPbfpILYyTheN78H4p+I9OKR9GkOMwiT49TNaIL4y
B5yg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1709742547; x=1710347347;
h=content-transfer-encoding:in-reply-to:from:content-language
:references:to:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=LQ4ulc40tnz1bGB3wRC6MLEzpC/T+82cBXegozNmJF0=;
b=kf4VGbNkH/56M7vb1viTErpPeMQjVf6v7O5JcdIXSQiPm9hLmFxnvhuc3Vf/XeWZwp
SW5j0VEcaz5dTE4CSLsqYcrTHtcHth7Lvkabiui8LSxfUN2W2/LPE1v06W6ZuTyP396C
Q+QpdLkmgX1iuZEpXh5ck2NUEUNuqeC84M+CSE5yUfQlxxlcACTsX6qm0u4ME6HpMneH
uMd7tGsFgFp3TXqAWO08sek8/EEu6gY0TozIAg37l/tDAPDggCcgMqS1EOJKB5Oop7Yy
25n7sR4XaWs3M3A8iMmAaPNVSMJ7L51Ef8JIb3hrxWeYJMM8gDxGzIlQR5JNww7LXsGd
DcEw==
X-Gm-Message-State: AOJu0YzNqh/Xv7NHlgbwvmIFTaPL7Meg8wssHcGt786d8MJNtjiZ806F
8PKh4K0PNN5uo+zoeg1B49x5IDLzRWMWsSRfDflkLTQLd4wVEUbapLRRh13i
X-Google-Smtp-Source: AGHT+IEmLbvNUao7KRKYTPxoilstPoJOCUGJUsB7UL+st/iHAOPogEARSa22LTkBqboZTf9dhtt4bA==
X-Received: by 2002:a17:906:4087:b0:a45:ad81:4ab3 with SMTP id
u7-20020a170906408700b00a45ad814ab3mr3620682ejj.54.1709742546517;
Wed, 06 Mar 2024 08:29:06 -0800 (PST)
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <2248adf8-551f-4e86-8de8-be892d5978ed@tompassin.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: <9c71abb0-b28d-4646-b130-9a4fdd529428@gmail.com>
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>
<2248adf8-551f-4e86-8de8-be892d5978ed@tompassin.net>
 by: Jacob Kruger - Wed, 6 Mar 2024 16:28 UTC

Thanks for all your input people, and, yes, I know that besides the
scope oddities the rest of the code is not my normal style either - was
partly due to forms of experimentation to try figure out what could be
causing issues. For example, instead of [:] syntax, was specifically
using copy() to make sure was not interacting with original variable
values, etc.

This will be a bit longer - copying-pasting command line output here to
show you what I truly mean - first session, where I am importing code
into interpreter and second session where I retype exact same code
behave differently:

#---first session---

C:\temp\py_try>type scoping2.py
from datetime import datetime, timezone, timedelta

dt_expiry = datetime.strptime("1970-01-01 00:00", "%Y-%m-%d
%H:%M").replace(tzinfo=timezone.utc)

def do_it():
    global dt_expiry
    dt_expiry = datetime.now()+timedelta(minutes=5)
    print(dt_expiry.strftime("%Y-%m-%d %H:%M"))
# end of do_it function

C:\temp\py_try>python
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec  4 2023, 19:24:49) [MSC v.1937
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from scoping2 import *
>>> print(dt_expiry)
1970-01-01 00:00:00+00:00
>>> do_it()
2024-03-06 18:12
>>> print(dt_expiry)
1970-01-01 00:00:00+00:00
>>>

#---end first session---

And, if I now retype the contents of the file into the python
interpreter instead:

#---start second session---

C:\temp\py_try>python
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec  4 2023, 19:24:49) [MSC v.1937
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime, timezone, timedelta
>>> dt_expiry = datetime.strptime("1970-01-01 00:00", "%Y-%m-%d
%H:%M").replace(tzinfo=timezone.utc)
>>> def do_it():
....     global dt_expiry
....     dt_expiry = datetime.now()+timedelta(minutes=5)
....     print(dt_expiry.strftime("%Y-%m-%d %H:%M"))
....
>>> print(dt_expiry)
1970-01-01 00:00:00+00:00
>>> do_it()
2024-03-06 18:20
>>> print(dt_expiry)
2024-03-06 18:20:03.909825
>>>

#---end second session---

So, in the second session, where retyped everything, it behaves as I
would expect it to, but, during first session, the variable is being
treated as a local variable inside the function - no code differences
since literally copied-pasted each and every line into console, but, a
different behaviour nonetheless?

So, yes, know this comes across like some form of a scam/joke, or
list-garbage, since it doesn't make any sense to me at all, but still
just wondering if missing something, or should I shift over to 3.12 to
see if if works differently, or just try reinstalling 3.11 from scratch,
or should I retry the above in something like the VS code console, or a
different python console, etc.?

Sorry

Jacob Kruger

Jacob Kruger
+2782 413 4791
"Resistance is futile!...Acceptance is versatile..."

On 2024/03/06 16:01, Thomas Passin via Python-list wrote:
> On 3/6/2024 7:55 AM, Jacob Kruger via Python-list wrote:
>> Ok, simpler version - all the code in a simpler test file, and
>> working with two separate variables to explain exactly what am
>> talking about:
>>
>> # start code
>>
>> from datetime import datetime, timezone, timedelta
>>
>> from copy import copy
>>
>>
>> # initialise original values
>>
>> dt_expiry = datetime.strptime("1970-01-01 00:00", "%Y-%m-%d
>> %H:%M").replace(tzinfo=timezone.utc)
>>
>> l_test = [1, 2, 3]
>>
>>
>> def do_it():
>>      global dt_expiry, l_test # asked python to refer to global
>> variables for both
>>
>>      # assign new value immediately
>>
>>      dt_expiry = datetime.now()+timedelta(minutes=5)
>>      print(dt_expiry.strftime("%Y-%m-%d %H:%M")) # just to show new
>> value has been assigned
>>      # grab copy of list for re-use of items
>>      l_temp = copy(l_test)
>>      # following line means l_test will later on retain value in
>> global scope because it was manipulated inside function instead of
>> just assigned new value
>>      l_test.clear()
>>      # replace original set of values
>>      for i in l_temp: l_test.append(i)
>>      # add new item
>>      l_test.append(99)
>> # end of do_it function
>>
>> # end code
>>
>>
>> If you import the contents of that file into the python interpreter,
>> dt_expiry will start off as "1970-01-01 00:00", and, if you execute
>> do_it function, it will print out the new value assigned to the
>> dt_expiry variable inside that function, but if you then again check
>> the value of the dt_expiry variable afterwards, it's reverted to the
>> 1970... value?
>
> Not when I run your code. With a little annotation added to the print
> statements I get (I added the import statements to make it run, and I
> used the same date-time formatting for all three print statements):
>
> List before: [1, 2, 3]
> start: 1970-01-01 00:00
> inside after reassignment: 2024-03-06 08:57
> outside after: 2024-03-06 08:57
> List after: [1, 2, 3, 99]
>
> As an aside, you have gone to some trouble to copy, clear, and
> reconstruct l_test.  It would be simpler like this (and you wouldn't
> have to import the "copy" library):
>
>     l_temp = l_test[:]
>     l_test = []
>
> Instead of those lines and then this:
>
>     for i in l_temp: l_test.append(i)
>
> you could achieve the same thing with this single statement:
>
>     l_test = l_test[:]
>>
>> If I take out the line that removes values from l_test #
>> l_test.clear() # before appending new value to it, then it will also
>> not retain it's new/additional child items after the function exits,
>> and will just revert back to [1, 2, 3] each and every time.
>>
>>
>> In other words, with some of the variable/object types, if you use a
>> function that manipulates the contents of a variable, before then
>> re-assigning it a new value, it seems like it might then actually
>> update/manipulate the global variable, but, either just calling
>> purely content retrieval functions against said objects, or assigning
>> them new values from scratch seems to then ignore the global scope
>> specified in the first line inside the function?
>>
>>
>> Hope this makes more sense
>>
>>
>> Jacob Kruger
>> +2782 413 4791
>> "Resistance is futile!...Acceptance is versatile..."
>>
>>
>> On 2024/03/05 20:23, dn via Python-list wrote:
>>> Jacob,
>>>
>>> Please reduce the problem to a small code-set which reproduces the
>>> problem. If we can reproduce same, then that tells us something. At
>>> the very least, we can experiment without having to expend amounts
>>> of time in a (likely faulty) bid to reproduce the same environment.
>>>
>>> Also, code is the ultimate description!
>>>
>>>
>>> Perhaps start with a small experiment:
>>>
>>> - after l_servers is created, print its id()
>>> - after the global statement, print its id()
>>> - after the clear/reassignment, print its id()
>>>
>>> Is Python always working with the same list?
>>> Please advise...
>>>
>>>
>>> On 6/03/24 07:13, Jacob Kruger via Python-list wrote:
>>>> Hi there
>>>>
>>>>
>>>> Working with python 3.11, and, issue that confused me for a little
>>>> while, trying to figure out what was occurring - unless am
>>>> completely confused, or missing something - was that, for example,
>>>> when having pre-defined a variable, and then included it in the
>>>> global statement inside a function, that function was still
>>>> referring to a completely local instance, without manipulating
>>>> outside variable object at all unless I first executed a form of
>>>> referral to it, before then possibly assigning a new value to it.
>>>>
>>>>
>>>> Now, this does not seem to occur consistently if, for example, I
>>>> just run bare-bones test code inside the python interpreter, but
>>>> consistently occurs inside my actual testing script.
>>>>
>>>>
>>>> Basically, in a file with python code in that am using for a form of
>>>> testing at the moment, at the top of the file, under all the import
>>>> statements, I initiate the existence of a list variable to make use of
>>>>
>>>> later:
>>>>
>>>>
>>>> # code snippet
>>>>
>>>> l_servers = []
>>>>
>>>> # end of first code snippet
>>>>
>>>>
>>>> Then, lower down, inside a couple of different functions, the first
>>>> line
>>>> inside the functions includes the following:
>>>> # code snippet
>>>>      global l_servers
>>>> # end code snippet
>>>>
>>>> That should, in theory, mean that if I assign a value to that variable
>>>> inside one of the functions, it should reflect globally?
>>>>
>>>> However, it seems like that, while inside those functions, it can be
>>>> assigned a new list of values, but if I then return to the scope
>>>> outside
>>>>
>>>> the functions, it has reverted back to being an empty list = []?
>>>>
>>>>
>>>> The issue seems to specifically (or not) occur when I make a call
>>>> to one function, and, in the steps it's executing in one context,
>>>> while it's not doing anything to the list directly, it's then
>>>> making a call to the second function, which is then meant to
>>>> repopulate the list with a brand new set of values.
>>>>
>>>>
>>>> Now, what almost seems to be occurring, is that while just
>>>> manipulating the contents of a referenced variable is fine in this
>>>> context, the moment I try to reassign it, that's where the issue is
>>>> occurring .
>>>>
>>>>
>>>> Here are relevant excerpts from the file:-
>>>>
>>>>
>>>> # start code
>>>>
>>>> # original assignation in main part of file
>>>>
>>>> l_servers = []
>>>>
>>>>
>>>> # function wich is initially being executed
>>>>
>>>> def interact():
>>>>      global l_servers
>>>>      # extra code inbetween choosing what to carry out
>>>>
>>>>      # ...
>>>>
>>>>      # end of other code
>>>>
>>>>      bl_response, o_out = list_servers()
>>>>
>>>>      if bl_response: # just make sure other function call was
>>>> successful
>>>>
>>>>          l_servers.clear() # first make reference to global variable
>>>>
>>>>          for srv in o_out: l_servers.append(srv) # now re-populate
>>>> items
>>>>
>>>>      # end code snippet from inside interact function
>>>>
>>>> # end of interact function
>>>>
>>>> # end of code snippet
>>>>
>>>>
>>>> That other function being called from within, list_servers() was
>>>> initially just trying to populate the values inside the global list
>>>> variable itself, but was ending up in a similar fashion - reverting
>>>> to initial empty value, but, the above now seems to work, as long
>>>> as I first make reference to/manipulate/work with global variable
>>>> instead of just trying to reassign it a brand new value/set of items?
>>>>
>>>>
>>>> So, am I missing something obvious, have I forgotten about
>>>> something else - yes, know that if was working from within an
>>>> embedded function, I might need/want to then use the nonlocal
>>>> statement against that variable name, but, honestly, just not sure
>>>> how this can be occurring, and, it's not just with this one list
>>>> variable, etc.?
>>>>
>>>>
>>>> If I try simple test code from within the python interpreter, using
>>>> different types of variables, this does also not seem to be the
>>>> same all the time, but, don't think it can relate to an iterable
>>>> like a list, or else, just in case, here is the code snippet with
>>>> all the import statements from the top of that file, in case
>>>> something could be overriding standard behaviour - not likely in
>>>> this context, but, really not sure what's occurring:
>>>>
>>>> # import code snippet
>>>>
>>>> import requests, time
>>>> from requests.auth import HTTPBasicAuth
>>>> import psutil as psu
>>>> import pytz
>>>> import bcrypt
>>>> from copy import copy
>>>> from datetime import datetime, timedelta, timezone
>>>> from dateutil.parser import parse
>>>>
>>>> # end of import snippet
>>>>
>>>>
>>>> Thanks if you have any ideas/thoughts on the matter
>>>>
>>>>
>>>> Jacob Kruger
>>>> +2782 413 4791
>>>> "Resistance is futile!...Acceptance is versatile..."
>>>>
>>>>
>>>
>


Click here to read the complete article
Re: Variable scope inside and outside functions

<scope-20240306173836@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!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: 6 Mar 2024 16:40:26 GMT
Organization: Stefan Ram
Lines: 22
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <scope-20240306173836@ram.dialup.fu-berlin.de>
References: <mailman.48.1709742549.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 O1OZ6wP8lc7VqphvRnnH4A1l1axpOK6fIq/yWa0MZiPuhK
Cancel-Lock: sha1:YDAls/P9sryB8l8EU3tfFu8eXyU= sha256:RvqxH4z35j4J4cpL+ium4mihhpyosFhUO9wmRlsRY0g=
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
 by: Stefan Ram - Wed, 6 Mar 2024 16:40 UTC

Jacob Kruger <jacob.kruger.work@gmail.com> wrote or quoted:
> >>> from scoping2 import *

Now, "dt_expiry" exists in /two/ modules: In "scoping2" and in the
current module (as a copy). To avoid this, "import scoping2" instead.

> >>> print(dt_expiry)
>1970-01-01 00:00:00+00:00
> >>> do_it()
>2024-03-06 18:12

This changes the variable "dt_expiry" in "scoping2", but not the
copy (also named "dt_expiry") in the current module.

> >>> print(dt_expiry)
>1970-01-01 00:00:00+00:00

This prints "dt_expiry" from the current module, not from "scoping2".

To avoid this, replace "from scoping2 import *" by "import scoping2"
and replace the "dt_expiry" in the two print statements by
"scoping2.dt_expiry".

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor