Hi, I have a small test program written trying to set up a dictionary that points keys to functions. It is working. However, in the process of creating it I noticed a weird problem. The problem is that this IS WORKING and I think it shouldn't be.
~ Here is the input config file code ~ its called config.file and is referenced from the script. [MAPS] relmap = 1 posmap = 1 asnmap = 1 ~ Here is the code that is working but I feel that it shouldn't be ~ import ConfigParser config = ConfigParser.ConfigParser() config.read("config.file") sections = config.sections() print config.options('MAPS') def posmap(): print "posmap function" def relmap(): print "relmap function" def asnmap(): print "asnmap function" for value in config.options('MAPS'): value map_library = { 'posmap': posmap() ,'relmap': relmap() ,'asnmap': asnmap() } ~ Output ~ ['posmap', 'relmap', 'asnmap'] posmap function relmap function asnmap function ~ The reason I'm confused is because when I change the code (Take away the map_library dictionary) import ConfigParser config = ConfigParser.ConfigParser() config.read("config.file") sections = config.sections() print config.options('MAPS') def posmap(): print "posmap function" def relmap(): print "relmap function" def asnmap(): print "asnmap function" for value in config.options('MAPS'): value ~ The output is the following ~ ['posmap', 'relmap', 'asnmap'] Is this defaulting to the dictionary and making it work? In the first set of code I don't reference the map at all but it still seems to know where to look? I am considerably new to Python
-- http://mail.python.org/mailman/listinfo/python-list