Hello hello,
I am writing to you because I am having trouble obtaining something: I know it should be doable, but can't seem to make an example.
I need to be able to run scripts from another central script. And as i' ve been reading, apparently they mustn't be imported as modules because the __name__ attribute of the module changes...etc.
The problem is that I want to have a class instance I make in my central script available in the rest. Like this:
CentralScript.py
class Mine:
def __init__(self, x, y):
self.X = x
self.Y = y
def PrintMe(self):
print 'My X: ',self.X
print 'My Y: ',self.Y
def ChangeMe(self, X, Y):
self.X = X
self.Y = Y
m = Mine(2,3)
m.PrintMe()
m.ChangeMe(10,11)
m.PrintMe()
#Call to script SecondaryScript here....
The problem seems obvious, m is not known in the SecondaryScript.py
m.ChangeMe(100,101)
m.PrintMe()
And somehow I've heard that it works...Do you have any suggestions as for the mistakes I'm making?
I'd appreciate it very much, thanks...
T