# List all sections in a config file - Python
Data Science for Political and Social Phenomena
Author: Guillaume Redoulès

# List all sections in a config file

A config file is partionned in sections.Here is an examples of a config file named `config.ini` :

    [section1]
    var_a:hello
    var_b:world
    [section2]
    myvariable: 42

There are two sections in this config file, you can access to them in python by calling the `sections` method of the ConfigParser class

    import configparser

    config = configparser.ConfigParser()
    config.read("config.ini")
    config.sections()

    ['section1', 'section2']

### Find an error or bug? Have a suggestion?

Everything on this site is avaliable on GitHub. Head on over and submit an issue. You can also message me directly by email.