How to access and modify the contents of one object created by one script from another script in python? -
i have 3 scripts written in python.
- an initialization script
- a script contains custom data structure class
- a monitoring script.
the initialization script starts first. creates object of custom data structure , starts monitoring script. monitoring script @ points send values fill object created in initialization script.
so, there global data object created initialization script. monitoring script add data object. data object buffer contains tasks executed later.
how accomplish task of adding data data object monitor script?
example scripts:
initialization script:
import monitorscript import customdatastructure # creates object customdatastructure # starts monitor script
custom data structure:
class mydata(object): def __init__(self, arg1 = none, arg2 = none): self.arg1 = arg1 self.arg2 = arg2 class mydata2(mydata): def __init__(self): self.queue = [] self.length = 0 def addtask(self, data): # adds task executed buffer. self.queue.append(data) # data mydata object. self.length += 1 # other methods.
monitor script:
# script want able add values data object created earlier.
if question unclear or needs more information, please ask me in comments. might missing whole programming concept on here. so, if can tell me need into, grateful.
in short, need able update data object created 1 script using script. data object buffer processed separately @ regular intervals.
unless explicitly pass data structure monitor module, you're going run issues. globals exist @ module level , aren't directly shared, when import resource 1 module another.
Comments
Post a Comment