How to read a config file using python
Question: I have a config file `abc.txt` which looks somewhat like:

    
    
    path1 = "D:\test1\first"
    path2 = "D:\test2\second"
    path3 = "D:\test2\third"
    

I want to read these paths from the `abc.txt` to use it in my program to avoid
hard coding.


Answer: In order to use my example,Your file "abc.txt" needs to look like:

    
    
    [your-config]
    path1 = "D:\test1\first"
    path2 = "D:\test2\second"
    path3 = "D:\test2\third"
    

Then in your software you can use the config parser:

    
    
    import ConfigParser
    

and then in you code:

    
    
     configParser = ConfigParser.RawConfigParser()   
     configFilePath = r'c:\abc.txt'
     configParser.read(configFilePath)
    

Use case:

    
    
    self.path = configParser.get('your-config', 'path1')
    

