Are these good ideas?
Weatherby,Gerard
gweatherby at uchc.edu
Mon Nov 14 12:42:45 EST 2022
Issue 1.
Depends very much on your operating system and application environment.
Issue 2.
I usually make myself a data class to pass around. Then when I figure out I forgot something, I just update the dataclass and the creator and consumer of it.
@dataclass
class CallParameter:
first : int
second: str
etc. I use context specific names, not “first” et. al.
From: Python-list <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of Stephen Tucker <stephen_tucker at sil.org>
Date: Monday, November 14, 2022 at 12:16 PM
To: Python <python-list at python.org>
Subject: Are these good ideas?
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***
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.
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hb_4MXkjG1NsyGoNsLJNDTOruPzfPWJKD-6vj0_2N1yqqtvz8oDZH3cT0EVkFbPTzSC19cAOgXlQdkDp7FZjwbyOjw$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hb_4MXkjG1NsyGoNsLJNDTOruPzfPWJKD-6vj0_2N1yqqtvz8oDZH3cT0EVkFbPTzSC19cAOgXlQdkDp7FZjwbyOjw$>
More information about the Python-list
mailing list