Python Global Object Variable
I want to make use on an object that has been instantinated inside of a class from a standalone module. I am trying to do this by makeing the object reference global. I think I wan
Solution 1:
You must declare global variable outside from class.
## Code file something.py
import moduleFile
adminMenu = None
class A():
def checkAdmin(self):
global adminMenu
adminMenu = SRMadminMenu()
then moduleFile.py,
from something import adminMenu
def moduleFile_Admin_Menu():
global adminMenu
adminMenu.createSubMenu("Module Administration")
Note: If you will not change adminMenu variable, you don't have to write global adminMenu
Post a Comment for "Python Global Object Variable"