From the course: Python Standard Library Essential Training
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Working with configuration files - Python Tutorial
From the course: Python Standard Library Essential Training
Working with configuration files
- [Instructor] When writing programs in the real world, it is fairly common to store various bits of settings and other configuration-related data in separate external files, so that the information isn't hard-coded into your program. The Python Standard Library provides a module named configparser for working with these kinds of files. This is what a typical configuration file looks like and this format was popularized by a Microsoft Windows, although it is widely used on other systems as well. It's essentially a collection of key value pairs organized into various sections. This particular file has three sections, the top one is named Default and then there are sections one and two. Within each section are our keys, which are on the left. And then values, which are on the right. So, we're going to write some code that parses and reads the values from this file. So, let's open config_start.py. You can see that I've imported the configparser module already. So to read a config file…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.