Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I am utilizing ConfigParser to read the runtime setup of a script. 

I might want to have the adaptability of not giving a part name (there are scripts that are sufficiently basic; they needn't bother with a 'section'). ConfigParser will toss a NoSectionError exception, and won't acknowledge the record. 

How might I make ConfigParser essentially recover the (key, value) tuples of a config record without section names?

For instance:

key1=val1

key2:val2

I would prefer not to write to the config record.

1 Answer

0 votes
by (26.4k points)
edited by

Alex Martelli gave an answer for utilizing ConfigParser to parse .properties records (which are clearly area-less config documents). 

His answer is a document-like wrapper that will amazingly embed a spurious segment making a beeline for fulfill ConfigParser's prerequisites.

Looking for a good course to learn python in detail? Better join our Python training course.

Browse Categories

...