In my project we use a config file that's parsed with the configparser module. Is there any way to cache the entire config file, and then use configparser methods to read it from memory? I'm hoping to not have to just store the config variables in a dictionary and look them up that way since using the configparser is really tightly coupled with a lot of our app and I'm hoping I can just change where the config is located to point to memory instead of a file name. Is this possible?
Yep. If you use the StringIO module, you can create a file-like object that is in memory.
Then you can use the method (ConfigParser inherits from RawConfigParser):
RawConfigParser.readfp(fp[, filename]) Read and parse configuration data from the file or file-like object in fp (only the readline() method is used). If filename is omitted and fp has a name attribute, that is used for filename; the default is .