Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in configparser
#10
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
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
Reply


Messages In This Thread
Error in configparser - by fullstop - Dec-21-2019, 07:45 AM
RE: Error in configparser - by Larz60+ - Dec-21-2019, 08:15 AM
RE: Error in configparser - by fullstop - Dec-21-2019, 08:20 AM
RE: Error in configparser - by buran - Dec-21-2019, 08:26 AM
RE: Error in configparser - by fullstop - Dec-21-2019, 08:29 AM
RE: Error in configparser - by buran - Dec-21-2019, 08:56 AM
RE: Error in configparser - by fullstop - Dec-21-2019, 09:04 AM
RE: Error in configparser - by buran - Dec-21-2019, 09:14 AM
RE: Error in configparser - by snippsat - Dec-21-2019, 10:01 AM
RE: Error in configparser - by snippsat - Dec-22-2019, 06:44 PM
RE: Error in configparser - by fullstop - Dec-22-2019, 07:03 PM
RE: Error in configparser - by snippsat - Dec-22-2019, 07:36 PM
doubt in configparser - by fullstop - Dec-22-2019, 05:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ConfigParser(dict_type=) not behaving as expected malonn 5 3,366 Sep-08-2022, 08:42 AM
Last Post: malonn
  using alternate names in configparser Skaperen 6 2,901 Oct-01-2020, 08:27 PM
Last Post: Skaperen
Question configparser.NoSectionError (Python 3.7) alpho 2 5,873 Apr-08-2020, 10:26 PM
Last Post: micseydel
  Help with ConfigParser EricALionsFan 3 3,286 Jul-27-2018, 08:46 PM
Last Post: buran
  ConfigParser.NoSectionError: No section: 'Default' degenaro 1 14,518 Jun-08-2018, 08:33 PM
Last Post: ljmetzger
  No module named 'ConfigParser' Bani 13 56,546 May-22-2017, 08:02 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020