Local variable in each class - python timed loop
<p>I have a python file in a continuous loop reading from an external file, I have a lot of different data points I'm reading and have a class (fb) that I'm calling to feed the locations of each point (m1.x, m2.x etc....) The file loops every 30 seconds. </p>

<p>I need a variable in the loop which is not reset for each instance I'm using. If I define it within the loop it's reset and if I use a global variable I can't use it for multiple variables. </p>

<p>So in the example below 'test' counts by one for all instance as its a global variable and self.X is reset after each loop. Neither of which do what I need. I was attempting to use threading but this causes even more problems with the modules I'm using. So if anyone has any ideas on how to create a local variable which is not reset within a class which is looping that would be great. Thanks. </p>

<pre><code>test = 0  
s = sched.scheduler(time.time, time.sleep)

def loop1(sc): 
    class fb:
        def link(self):
            global test
            test = test + 1
            print test

            self.X = self.X + 1
            print self.X

    m1 = fb()

    m1.X = 1
    m1.link()

    m2 =fb()
    m2.X = 0
    m2.link()

    # Update loop every 10 second    
    sc.enter(10, 10, loop1, (sc,))


# end loop
s.enter(1, 1, loop1, (s,))
s.run()
</code></pre>
