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']