In Python, access variable defined in main from another module -
i'm writing python program in main script initializes several variables common data command line, config file, etc. want rest of program able access them globals:
def abc() : global xyz _someoptionvalue = xyz['someoptionname'] ...
it doesn't work. think because global defined in main.py
(for example) , function references defined in abc.py
(for example). consequently function's global namespace different main script's namespace.
i think should able @ global variable qualifying name name of main script's namespace, namespace's name?
context: pass these variables parameters, , know many programmers consider cleaner solution. in case not because variables set once, read throughout whole program. in judgement strongest possible case (and justified case) using global variables. if think shouldn't it, respect opinion, don't share it; please respect mine!
create globals
module contains shared information, , have every module (including main) import module.
Comments
Post a Comment