Duncan Booth said:
There isn't really such a thing as a forward reference in Python. Always
remember that 'def' and 'class' are executable statements:
Ok, we'll here's what I'm trying to do. I have a dictionary that I
would like to initialize in a module file config.py:
-- config.py -------------------------
global a_fun, b_fun
dict = {
'a': a_fun,
'b': b_fun
}
--------------------------------------
where a_fun and b_fun are in fun.py:
-- fun.py ----------------------------
def a_fun(): pass
def b_fun(): pass
import config
def main():
config.dict['a']()
config.dict['b']()
main()
--------------------------------------
I like having the module/namespace seperation with the configuration
variables but I would like to make them easily (re)defined in the
configuration file by the user. Does python have the idea of a 'weak'
reference or lazy style evaluation for the definition of the dict in
the config file above so I can achive what i'm tryin to do?