Update:
Here an example to prevent cross imports:
load_file.py
Code:
import os
import sys
# SET APP WIDE GLOBAL VARS
CWD = os.getcwd().replace(";","")
X = 5
# Init App
if ( __name__ == "__main__" ):
import external
mc.ActivateWindow(15000)
APP = external.load()
external.py
Code:
from load_file import *
class load():
def __init__(self):
#Your Code
Note that you want to prevent a cross import so 'load_file' imports 'external' and 'external' import 'load_file' etc. To prevent this you introduce the following code:
if ( __name__ == "__main__" ):
This is only executed if the file is launched directly (as main), but not on an import, thus preventing the execution of the code below it. Now you can call variable X from both the module and all the windows, but you can only call APP from your windows, but not from your module external as it is called after the main check.
Bookmarks