Alex Rivera | Logout

How to handle empty values in config files with ConfigParser?

Asked 2010-08-27T18:21:30.163
17

How can I parse tags with no value in an ini file with python configparser module?

For example, I have the following ini and I need to parse rb. In some ini files rb has integer values and on some no value at all like the example below. How can I do that with configparser without getting a valueerror? I use the getint function

[section]
person=name
id=000
rb=
Edit
Report

1 Answer

15

You need to set allow_no_value=True optional argument when creating the parser object.

answered 2010-08-27T18:27:42.380

Your Answer