Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

How can I read in lists within a list using ConfigParser() in Python?

$
0
0

I have seen a lot of answers on how to read in a list using ConfigParser in Python:

But I am wondering how I can read in a list with multiple lists

For example, I have a config.ini:

[INPUT]values = [[40000, 60000], [70000, 80000]]

A function in my main.py needs to read the above as:

[[40000, 60000], [70000, 80000]]

I am not sure if it matters, but values can be any size list, so for example:

[[40000, 60000]]

or

[[40000, 60000], [70000, 80000], [90000, 95000]]

I know the below will not work, but for clarity, I am reading the lists within the list into main.py like this:

self.values = config['INPUT']['values']

self is there because I am using a class. These are my declarations in the beginning of main.py:

import configparserconfig = configparser.ConfigParser()config.sections()config.read('config.ini')

Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>