Re: Passing information between modules

2022-11-21 Thread Barry
> On 21 Nov 2022, at 21:23, r...@zedat.fu-berlin.de wrote: > > dn writes: >> Now, at the config stage, take the instructions to define whichever the >> user prefers, and instantiate that class. Then the 'calling-routine' can >> use the instantiated object as an interface to whichever type of

Re: Passing information between modules

2022-11-21 Thread Thomas Passin
On 11/21/2022 12:24 AM, dn wrote: My original question probably was intended to be something    like: "Today, we can add attributes to a module from the    outside. How large is the risk that this will be forbidden    one day, so that all code using this will stop working?". This can happen tod

Re: Passing information between modules

2022-11-20 Thread Chris Angelico
On Mon, 21 Nov 2022 at 16:26, dn wrote: > Am put-off by the 'smell' of subverting/adapting names like print() = > surprise/confusion factor - but I think I understand where you're going. To be fair, redefining the "print" function IS one of the reasons that it's no longer a statement. Though I wo

Re: Passing information between modules

2022-11-20 Thread dn
On 21/11/2022 01.29, Stefan Ram wrote: dn writes: A 'standard' solution is to collect all such configuration-data at the start of the application, into an object (or other data-structure) - I usually call it "env" (an instantiation of "Environment"). Yeah, I had some functions of my librar

Re: Passing information between modules

2022-11-20 Thread Thomas Passin
On 11/21/2022 12:01 AM, dn wrote: On 21/11/2022 12.07, Dan Kolis wrote: If you understand its meaning, it achieves my purpose. If you don't I you're perhaps not a programmer... Ouch! Does the first sentence imply who is the more important person in the interaction? Does the second further th

Re: Passing information between modules

2022-11-20 Thread dn
On 21/11/2022 12.07, Dan Kolis wrote: If you understand its meaning, it achieves my purpose. If you don't I you're perhaps not a programmer... Ouch! Does the first sentence imply who is the more important person in the interaction? Does the second further the idea that anyone/everyone who i

Re: Passing information between modules

2022-11-20 Thread Thomas Passin
On 11/20/2022 4:07 PM, Roel Schroeven wrote: Thomas Passin schreef op 20/11/2022 om 20:33: https://devblogs.microsoft.com/oldnewthing/20050607-00/?p=35413 https://devblogs.microsoft.com/oldnewthing/20101125-00/?p=12203 Now that I think about it, The Old New Thing is also where I got the global

Re: Passing information between modules

2022-11-20 Thread Dan Kolis
Its advice, I don't think the style issue is particularly important. If you understand its meaning, it achieves my purpose. If you don't I you're perhaps not a programmer... I like the abruptness of technical writing as a style, actually. If that is how machine learning ( aka 'A.I.' ) tends to

Re: Passing information between modules

2022-11-20 Thread Chris Angelico
On Mon, 21 Nov 2022 at 09:37, Dan Kolis wrote: > > Using sys.stdout / is simply nonsense. The more I think about it, the more I > realise how bad it is. > > Going on about it endlessly seems pointless. > > If the even mini threading thing is turned on, now what ? some other module > eats the mes

Re: Passing information between modules

2022-11-20 Thread Dan Kolis
Using sys.stdout / is simply nonsense. The more I think about it, the more I realise how bad it is. Going on about it endlessly seems pointless. If the even mini threading thing is turned on, now what ? some other module eats the message intended for a different module ? A state machine with it

Re: Passing information between modules

2022-11-20 Thread Roel Schroeven
Thomas Passin schreef op 20/11/2022 om 20:33: https://devblogs.microsoft.com/oldnewthing/20050607-00/?p=35413 https://devblogs.microsoft.com/oldnewthing/20101125-00/?p=12203 Now that I think about it, The Old New Thing is also where I got the global vs local thing: "Don’t use global state to ma

Re: Passing information between modules

2022-11-20 Thread Thomas Passin
On 11/20/2022 1:50 PM, Roel Schroeven wrote: Stefan Ram schreef op 20/11/2022 om 11:39:    The idea is about parameterizing the behavior of a module.    For example, the module "M" may contain functions that contain    "input.read()" to get input and "output.write()" to write    output. Then one

Re: Passing information between modules

2022-11-20 Thread dn
On 21/11/2022 01.03, Stefan Ram wrote: dn writes: In some respects we have the (OP) problem because Python does not have "interfaces" as a formal component of the language. What one can do today is, class my_interface( metaclass=abc.ABCMeta ): """This interface ...""" @abc.abst

Re: Passing information between modules

2022-11-20 Thread Roel Schroeven
Stefan Ram schreef op 20/11/2022 om 11:39: The idea is about parameterizing the behavior of a module. For example, the module "M" may contain functions that contain "input.read()" to get input and "output.write()" to write output. Then one would write code like (the following is no

Re: Passing information between modules

2022-11-20 Thread Dan Kolis
It's certainly not an "incredibly bad idea", it is a mildly bad idea however. Why be stuck with maybe's and just text strings ? Functions as "first class operators" and object oriented languages are a natural pair with a bit of heavy thinking. The problem is... there is nobody giving you a 3

Re: Passing information between modules

2022-11-20 Thread Avi Gross
There is no guarantee that argv is consulted earlier in the program than other modules will use it for communication. Consider a case where a program does look at argv but later wants to call another program using some or all of the components of argv and now there are added components there. That

Re: Passing information between modules

2022-11-19 Thread Dan Kolis
In a module mostly for this purpose; ( big program means many modules aka files ): -- globalIdeas.py -- # Empty object maker ( M T ) ...

Re: Passing information between modules

2022-11-19 Thread Cameron Simpson
On 18Nov2022 10:53, Stefan Ram wrote: Can I use "sys.argv" to pass information between modules as follows? [...] Stefan, it looks like most of the replies take the form: yes you can do that but it is probably a bad idea. Could you outline the larger situation where you want to do this? O

Re: Passing information between modules

2022-11-19 Thread Thomas Passin
On 11/19/2022 3:46 PM, Michael F. Stemper wrote: On 18/11/2022 04.53, Stefan Ram wrote:    Can I use "sys.argv" to pass information between modules    as follows?    in module A: import sys sys.argv.append( "Hi there!" )    in module B: import sys message = sys.argv[ -1 ] I just tried and

Re: Passing information between modules

2022-11-19 Thread Thomas Passin
On 11/19/2022 4:28 PM, Thomas Passin wrote: On 11/19/2022 3:46 PM, Michael F. Stemper wrote: On 18/11/2022 04.53, Stefan Ram wrote:    Can I use "sys.argv" to pass information between modules    as follows?    in module A: import sys sys.argv.append( "Hi there!" )    in module B: import sys

Re: Passing information between modules

2022-11-19 Thread Michael F. Stemper
On 18/11/2022 04.53, Stefan Ram wrote: Can I use "sys.argv" to pass information between modules as follows? in module A: import sys sys.argv.append( "Hi there!" ) in module B: import sys message = sys.argv[ -1 ] I just tried and it appears that one can append to sys.argv. Howeve

Re: Passing information between modules

2022-11-19 Thread dn
On 18/11/2022 23.53, Stefan Ram wrote: Can I use "sys.argv" to pass information between modules as follows? in module A: import sys sys.argv.append( "Hi there!" ) in module B: import sys message = sys.argv[ -1 ] . "sys.argv" is said to be a list by the standard documentatio

Re: Passing information between modules

2022-11-18 Thread Axy via Python-list
On 18/11/2022 10:53, Stefan Ram wrote: Can I use "sys.argv" to pass information between modules as follows? in module A: import sys sys.argv.append( "Hi there!" ) in module B: import sys message = sys.argv[ -1 ] This idea has a couple of flaws so can be regarded as bad. However

Re: Passing information between modules

2022-11-18 Thread Thomas Passin
On 11/18/2022 10:19 AM, Tobiah wrote: On 11/18/22 02:53, Stefan Ram wrote:    Can I use "sys.argv" to pass information between modules    as follows?    in module A: import sys sys.argv.append( "Hi there!" )    in module B: import sys message = sys.argv[ -1 ] Kind of seems like a code smel

Re: Passing information between modules

2022-11-18 Thread Tobiah
On 11/18/22 02:53, Stefan Ram wrote: Can I use "sys.argv" to pass information between modules as follows? in module A: import sys sys.argv.append( "Hi there!" ) in module B: import sys message = sys.argv[ -1 ] Kind of seems like a code smell. I think you would normally just inj