I want to write an ini file with if else conditions that i parse it with ConfigParser in python.
How to use if and Else statements in ini File ??
If I understand what you're asking...
What you're probably looking to do is something like this:
Set the value of the conditions in the INI file...
[section_1]
condition_a = true
condition_b = false
condition_c = false
Read in the conditions' boolean values using getboolean()...
import ConfigParser
config = ConfigParser()
config.read('my_file.ini')
if config.getboolean('section_1', 'condition_a'):
# Run your first conditional code
if config.getboolean('section_1', 'condition_b'):
# Run your second conditional code
if config.getboolean('section_1', 'condition_c'):
# Run your third conditional code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With