["python"]
How to read a config file using python

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.
In order to use my example, your file "abc.txt" needs to look like this. [your-config] path1 = "D:\test1\first" path2 = "D:\test2\second" path3 = "D:\test2\third" Then in your code you can use the config parser. import ConfigParser configParser = ConfigParser.RawConfigParser() configFilePath = r'c:\abc.txt' configParser.read(configFilePath) As human.js noted in his comment, in Python 3, ConfigParser has been renamed configparser. See Python 3 ImportError: No module named 'ConfigParser' for more details.