Dec-22-2019, 05:25 PM
I have a config file (abc.ini) as below. It just have one Section with an item name= None
[Section]
name = None
Now I am calling this in my main python code as below
Also, it it not adding any item to Section. I mean if I do
print(config["Section"]["new_var"]), I will give an error
[Section]
name = None
Now I am calling this in my main python code as below
import configparser config = configparser.ConfigParser() config.read("abc.ini",encoding="utf-8") config["Section"].new_var = "surname"Now my problem is with last line of code. This works ok. If I check the type config["Section"].new_var, it is of class str. Now if new_var is not a method or attribute of config["Section"], how it works OK.
Also, it it not adding any item to Section. I mean if I do
print(config["Section"]["new_var"]), I will give an error