I have this start.py:
# start.py
class Start:
    def __init__(self):
        self.mylist = []
    def run(self):
        # some code
Executing its run() method will at some point invoke the put_item(obj) method in moduleX.py:
# moduleX.py
def put_item(obj):
    # what should I write here
run() is NOT the direct caller of put_item(obj). In fact, from run() to put_item(obj) the execution is quite complex and involves a lot of other invocations. 
My problem is, when put_item(obj) is called, can I directly add the value of obj back to mylist in the class Start? For example:
s = Start()
# suppose during this execution, put_item(obj) has been 
# invoked 3 times, with obj equals to 1, 2, 3 each time
s.run() 
print(s.mylist) # I want it to be [1,2,3]
UPDATE:
- From - run()to- put_item(obj)the execution involves heavy usages of 3rd-party modules and function calls that I have no control over. In other words, the execution inbetween- run()to- put_item(obj)is like a blackbox to me, and this execution leads to the value of- objthat I'm interested in.
- objis consumed in- put_item(obj)in- moduleX.py, which is also a 3rd-party module.- put_item(obj)originally has GUI code that displays- objin a fancy way. However, I want to modify its original behavior such that I can add- objto- mylistin class- Startand use- mylistlater in my own way.
- Therefore, I cannot pass - Startreference along the call chain to- put_itemsince I don't know the call chain and I simply cannot modify it. Also, I cannot change the method signatures in- moduleX.pyotherwise I'll break the original API. What I can change is the content of- put_item(obj)and the- start.py.
 
     
    