Yes, you want the configparser module
this should get you going:
configexample.py
import configparser
# note that this is for python3. Some changes need to be made for python2
# create parser object and read config file
config = configparser.RawConfigParser()
config.read('myconfig.cfg')
# loop through. Here for instructional purposes we print, but you can
# assign etc instead.
for section in config.sections():
print(section)
for option in config.options(section):
text = '{} {}'.format(option, config.get(section,option))
print(text)
The section in the code extracts the contents of the brackets []. Here is an example configuration file myconfig.cfg
[auth]
username= Petra
password= topsecret
[database]
server= 192.168.1.34
port= 143
file='thatfile.dat'
[Location]
language = English
timezone = UTC
For more details have a look at the documentation.
Addendum: Incase you are interested you can also use the json and shlex modules too.