'PYTHON: Updating specific value from the class list into another file

in File1 I do some operations like this:

import threading
import time

class Action:
    runner = Another_Class()
    def __init__(self):
        runner_thread = threading.Thread(target=self.run_loop, daemon=True)
        runner_thread.start()
        time.sleep(1)
        self.something = []
        self.percent = []

    def run_loop(self):
            self.runner.run()

    def update(self, data):
        self.something.append(data)
        if len(self.something) > 1:
            percentage = round(((self.something[-1] - self.something[-2]) / self.something[-2] * 100), 5)
            self.percent.append(percentage)

action = Action()

Output is appending lists, because of data is connecting to Another_Class which is receiving real time data.

How to import specific value from lists to File2 like:

import File1

foo = File1.action
foo_something = foo.something[-1]
foo_percent = foo.percent[-1]

where foo_something and foo_percent will be constantly updating while File1 is running? I show you pseudocode for File2 because I got different errors like list index out of range



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source