Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You will have a head crash on your private pack.


devel / comp.lang.python / Re: Are these good ideas?

SubjectAuthor
o Re: Are these good ideas?Paul Bryan

1
Re: Are these good ideas?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: pbr...@anode.ca (Paul Bryan)
Newsgroups: comp.lang.python
Subject: Re: Are these good ideas?
Date: Mon, 14 Nov 2022 09:30:13 -0800
Lines: 57
Message-ID: <mailman.977.1668447020.20444.python-list@python.org>
References: <CAP=-cKXmUobHdy7QoZjiUoseDDQt5ErnFRj2OEi+cwjtbg_JLA@mail.gmail.com>
<e60a0b969788799781ed73224ab734b475e5a5f6.camel@anode.ca>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de f7bm3wC0IyGnpQGz1a5deAXFtPWrkiv4dEUX5JdKVp4Q==
Return-Path: <pbryan@anode.ca>
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=anode.ca header.i=@anode.ca header.b=RBihVuSb;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'comments': 0.03;
'repository': 0.05; 'wanting': 0.07; 'describe': 0.09; 'module.':
0.09; 'tasks,': 0.09; 'import': 0.15; '(b)': 0.16; '(i)': 0.16;
'(ii)': 0.16; '(iii)': 0.16; 'functions.': 0.16; 'functions;':
0.16; 'layers': 0.16; 'low-level': 0.16; 'passing.': 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; 'wrote:': 0.16; 'values':
0.17; 'to:addr:python-list': 0.20; 'issue': 0.21; 'communicate':
0.22; 'run': 0.23; "i'd": 0.24; 'idea': 0.24; 'actual': 0.25;
'seems': 0.26; 'function': 0.27; 'wrong': 0.28; 'header:User-
Agent:1': 0.30; 'module': 0.31; 'concerned': 0.32; 'context':
0.32; 'to:name:python': 0.32; 'but': 0.32; 'header:In-Reply-To:1':
0.34; 'particularly': 0.35; 'functions': 0.36; 'mon,': 0.36;
'subject:ideas': 0.36; 'those': 0.36; 'missing': 0.37; 'using':
0.37; 'way': 0.38; 'could': 0.38; 'two': 0.39; 'this,': 0.39;
'considering': 0.39; 'use': 0.39; 'on.': 0.39; 'situation': 0.40;
'reasonable': 0.62; 'subject': 0.63; 'once': 0.63; 'pass': 0.64;
'down': 0.64; 'supply': 0.65; 'well': 0.65; 'years': 0.65;
'received:64': 0.67; 'that,': 0.67; 'per': 0.68; 'order': 0.69;
'above,': 0.70; 'managers': 0.70; 'carry': 0.71; 'global': 0.73;
'subject:good': 0.76; '(c)': 0.81; 'comments,': 0.84;
'subject:these': 0.84; '\xe2\x80\xa6': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anode.ca; h=cc
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:sender:subject
:subject:to:to; s=fm1; t=1668447015; x=1668533415; bh=g73CqF/up5
LjGzXs9fCjahhpU3XX3E95xf8Hifw3cn8=; b=RBihVuSbvw8RIE8tzEiPleqxAr
ptbahvcFqJhDIRnXngI8dZFEuyWpU76RJ/rSy8PQftTYM8W4ULc3xXb6CTTn5mn0
i+pq1VZw/d2Baw39SulJnkMTobbojCGFisuUthRPz6xjMTcyKyr8qh4ydChacE0i
224luuQfEF8BIJIoJPGCpk5VQX4jWQQZZVHzk6VC2yWJOjwMsnwMvY4PiiQ2mDSp
8HiU7Lo/xaO5Xic7jSbT8OnUmppBRBknKQK22H57kmpOK2pwOmeqMBMFKbkfxbh6
xgB7RbPHTRkV2Z9VVYK7V9oms14ZKmYV+KxDZ4ssJL3WG9IfkFveICHt3FPQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-type:date:date:feedback-id
:feedback-id:from:from:in-reply-to:in-reply-to:message-id
:mime-version:references:reply-to:sender:subject:subject:to:to
:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
fm1; t=1668447015; x=1668533415; bh=g73CqF/up5LjGzXs9fCjahhpU3XX
3E95xf8Hifw3cn8=; b=TrG8o+SeW/1AQyeEwysAeC/oHqdmUxNxOqdyPFIqefxF
1k5LWyBJJArgd7+dOLHU3bz7xEO9dl910wvZWtvCWBeMcq2tIjwO7Wb3bxlz1dOT
+2RnSuimzxYEjwyOVCnqS8OZ4OXROviHidi9TE2TzkYfhkTFNElR+iWM2lNokvzC
uAg1FYhSoLNtu1VeJu24f4qQCiV/9xV57TyDcOeP/JKJPcG8E7ccYun5NZTDn0he
M81mU64q6bRWs9YZFFyRAKnTk2GZhPJcxZ7A/PYdnXuDXT49Nli2ctJWsY1BuU+5
ojsvia0mhwUX5IYGnGjSJBQ3oLCw0ki6NVLvqfVHpQ==
X-ME-Sender: <xms:J3tyY4BhJG1qntzQUWboIZLM1Z0DflaTyA0wpoke63HREFlxkjAfSg>
<xme:J3tyY6ifDFKmr-HQloWxGB4cHCf_KqPhSLEd4FhDtR13rDnf8gpcT_tcwDqfsRkrC
EDQt-vb_yv05bS9pkc>
X-ME-Received: <xmr:J3tyY7lCER2LPnjJvBvbslVgRW_WlEuwfRLfCOd-E0IaLDTXfyySjrp5UtC-Pio_VE0L4N3i-NV4wpZ24-7fZPmvDC6apsyzpHfO5Q>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejfecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc
fjughrpefkuffhvfffjghftggfggesrgdtreertderjeenucfhrhhomheprfgruhhluceu
rhihrghnuceophgsrhihrghnsegrnhhouggvrdgtrgeqnecuggftrfgrthhtvghrnheple
duffefgfelveeileejgfeuudfhffekhfelkeejveevtdefffeuhefgteffuedvnecuffho
mhgrihhnpehphihthhhonhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrh
grmhepmhgrihhlfhhrohhmpehpsghrhigrnhesrghnohguvgdrtggr
X-ME-Proxy: <xmx:J3tyY-wKuxcEdAk1mtJhgG5jx5slk9F1Ut1tCtneIcuvU9opCiVkQQ>
<xmx:J3tyY9RyRxync2AIQ59ELUMu11Upg3ufyzyVlhNH6RYsR6dP93EkPA>
<xmx:J3tyY5b47G8AHPZGR4Y9EyeONgsQUKpC7QOCuqz4sXJAT7m_y07zMA>
<xmx:J3tyY-6dtCsZQrJnjuQIdgq07DSCYOZ48tQmfkJF-dqsUv_-EM7ahg>
Feedback-ID: i1ce14775:Fastmail
In-Reply-To: <CAP=-cKXmUobHdy7QoZjiUoseDDQt5ErnFRj2OEi+cwjtbg_JLA@mail.gmail.com>
User-Agent: Evolution 3.46.1
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: <e60a0b969788799781ed73224ab734b475e5a5f6.camel@anode.ca>
X-Mailman-Original-References: <CAP=-cKXmUobHdy7QoZjiUoseDDQt5ErnFRj2OEi+cwjtbg_JLA@mail.gmail.com>
 by: Paul Bryan - Mon, 14 Nov 2022 17:30 UTC

Seems like this is a use case for context managers and/or context
variables:

https://docs.python.org/3/library/contextlib.html
https://docs.python.org/3/library/contextvars.html

On Mon, 2022-11-14 at 17:14 +0000, Stephen Tucker wrote:
> Hi,
>
> I have two related issues I'd like comments on.
>
> Issue 1 - Global Values
>
> Some years ago, I had a situation where
> (a) I could supply low-level functions that carry out tasks,
> (b) I needed those functions to communicate with each other, but
> (c) I had no access to the module that invoked my functions.
>
> In order to achieve this, I hit on the idea that I also supply a
> module
> that I describe as a "global values" module. This module …
> (i) … defines the values that the functions use to communicate with
> each
> other;
> (ii) … is the subject of an import statement in each of my functions;
> (iii) … initialises its values at the start of each run (since the
> import
> only carries out an actual import once per session);
> (iv) … acts as a repository for the values thereafter.
>
> This solution works well.
>
> Given that I am not particularly concerned about efficiency,
> (1) Is this a reasonable way to achieve this goal?
> (2) Do you know of any better ways?
>
> Issue 2 - Passed Parameters
>
> I am now facing another situation where I am wanting to pass 6 or 7
> parameters down through several layers of logic (function A calling
> function B calling ... ) and for results to be passed back.
>
> Having had the idea described above, I am considering using it again
> to
> save all the parameter-and-results passing.
>
> I see nothing wrong with doing that, but I may well be missing
> something!
>
> Comments, please!
>
> Stephen Tucker.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor