Class object scope issues - Part2

Reference post: inductiveautomation.com/forum/v … 50&t=16600

While I was able to create a “global” class as suggested in the previous post, I am now having some difficulty with class instances being overwritten.
In the example below, does the instance x get overwritten with it’s initialized values (y=0) every time a call to run() is made from outside the module. For example, if I call this function from a tag value change event? and if so, how would I achieve a persistent class instance?

[code]class myclass:
def init(self)
self.y=0

x=myclass()

def run():
z = x.y[/code]

‘x’ does not get overwritten by run(). You must not assign to ‘x’ anywhere else, either. Keep in mind that editing your scripts and saving will re-initialize them, overwriting ‘x’ at that point.
As an alternative, try using ‘myPersDict={}’ at the top level of a script and then writing and accessing values within it.

The suggested alternative, storing values in a dictionary worked.
Thank you again.