How to use ConfigParser in Python with .ini file
In this article I’m going to show how the configparser module from Python works. This module is used for working with configuration files, which is very similar to Windows INI files.
The file is organized into sections, and each section can contain name-value pairs for configuration data, just like the example below.
The documentation of this Python module can be found here: configparser — Configuration file parser — Python 3.9.6 documentation
So what I’m going to use as an example is a Python script to connect to a simples API with and without the configparser module. But this module can be used with others commom usage like storing passwords, application defaults, configuration for databases, etc.
So after running my script called “API_with_configparser.py” we still can get the JSON response as the example below.
It’s a really simple Python script that can be found on my GitHub reporitory: guimatheus92/How-to-use-ConfigParser-in-Python: With this Python module, you can load a separate file with .ini extension. (github.com)
I hope you enjoyed this simple solution.