Use Config Files To Turn Your Python Script Into Reusable Assets

The ultimate guide to writing reusable Python Scripts with JSON, YAML, TOML, and INI configuration files

Akhilesh Mishra
5 min readJul 18, 2024
Photo by Mpho Mojapelo on Unsplash

When writing Python scripts, I like to make them dynamic and reusable. Hardcoding the configurations goes against this purpose.

I use configuration files to pass the configuration details in my Python scripts, it gives me the flexibility to write a good-looking, functional, and reusable code.

In this blog post, I will take you through using configuration files with the most popular formats .json, .yaml and .ini in your Python script.

Interesting Reads

1: Server Configuration Management Using JSON config files in Python.

JSON provides a lightweight, easy-to-read format for data interchange, making it perfect for APIs, web applications, and configurations requiring structured data. Its simplicity and structure cater well to modern development needs.

--

--

Akhilesh Mishra

DevOps engineer with expertise in multi-cloud, and various DevOps tools.