I have this very nasty python script which is, to say the least not very well managed and I'd like to improve it. The way I thought about doing that is breaking up the code into what they do and then importing them into the main function that runs everything. But some of my defs have a global (like the key word based global) in them, how do I scope those out in separate files exactly?
for example main,py wi have:
import function
message = {}
while (true):
function.function(message)
print(message)
and function,py has :
def function(some variables) :
global message
if (somevariable = something):
message = "xyz"
message in the second file is giving me an error
EDIT: So I see that I need to give a bit more context, there are infact 3 processes (functions) that are running and the global message is what I'm using to pass information between all these threads. So Ideally Id like to separate all the processes as different files and then keep adding them as a new thread. How do I go about this?