Jacek Generowicz wrote: > I am dealing with an application which reads in configurations by > calling (a wrapper around) execfile. Any configuration file may itself > execfile other configuration files in the same manner. > > I would like to create a log containing all global assignments made in > these files. Comparing the globals dictionaries before and after is > not quite enough, as > > a) this misses multiple assignments to the same name, within a single > file, > > b) doesn't allow me to pinpoint the line at which the assignment is > made. > > Inspecting the implementation of execfile suggests to me that the > assignments are performed by a hard-wired call to PyDict_SetItem, in > the opcode implementations, so it looks like ideas based on giving > execfile a globals dictionary with an instrumented __setitem__ are > probably doomed to failure. > > Is there any way of injecting some of my code into the process of > global name binding, or some other means of "capturing" global > assignments ?
Suggestion: Use ConfigParser to set your globals instead and you can track your assignments over each file, section and option in the file. Larry Bates -- http://mail.python.org/mailman/listinfo/python-list