Parth
Parth

Reputation: 1266

How do I set a value to None with ConfigParser?

I'm using ConfigParser in Python 2.7 to read from a config file and I'm wondering how to read a value such that it's set to the constant None in Python.

Currently, my code is as follows:

config.set("Test Series Parameters", "Test Series Parameter", None)

However, this shows up as Test Series Parameter = "None" (as a string).

Upvotes: 10

Views: 9962

Answers (1)

Carlos
Carlos

Reputation: 1935

According to the 2.7.2 docs:

When allow_no_value is true (default: False), options without values are accepted; the value presented for these is None. Does that help?

Upvotes: 22

Related Questions