Python Forum
name 'get_config' is not defined, config parser
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
name 'get_config' is not defined, config parser
#1
Hello, I was just testing changing values in .ini files.
I read forums and most people were saying that configparser is the best module to do so.
I've read on some forums and I wanted to try to do it myself
But this error comes out:
Error:
Traceback (most recent call last): File "C:\Users\P1tey\Desktop\test.py", line 10, in <module> update_setting("C:\\Users\\P1tey\\Desktop\\tests.ini", "Testsection", "resolutiony", "1440 x 1080") File "C:\Users\P1tey\Desktop\test.py", line 5, in update_setting config = get_config(path) NameError: name 'get_config' is not defined
Here is the code:

import configparser
import os

def update_setting(path, section, setting, value):
    config = get_config(path)
    config.set(section, setting, value)
    with open(path, "wb") as config_file:
        config.write(config_file)

update_setting("C:\\Users\\P1tey\\Desktop\\tests.ini", "Testsection", "resolutiony", "1440 x 1080")
And also, is there any more effective way to do the same thing?
Reply
#2
do you mean config.get ?
there is no get_config
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating a config file [solved] ebolisa 8 2,577 Nov-04-2021, 10:20 AM
Last Post: Gribouillis
  ImportError: cannot import name 'get_config' russray2008 0 4,739 Sep-20-2021, 02:18 PM
Last Post: russray2008
  NameError: name 'u1' is not defined (on parser code Python) Melcu54 1 2,873 Jul-26-2021, 04:36 PM
Last Post: snippsat
  Is there a library for recursive object creation using config objects johsmi96 0 1,843 May-03-2021, 08:09 PM
Last Post: johsmi96
  help with pytesseract.image_to_string(savedImage, config='--psm 11')iamge to string korenron 0 2,694 Apr-29-2021, 10:08 AM
Last Post: korenron
  Config file update Olivier74 0 1,474 Aug-18-2020, 03:36 PM
Last Post: Olivier74
  python library not defined in user defined function johnEmScott 2 3,843 May-30-2020, 04:14 AM
Last Post: DT2000
  What is the best way to set application-wide config values? ajorona 1 1,910 May-07-2020, 05:03 PM
Last Post: buran
  Config file entry as list versus string? taziuk 2 1,817 Apr-25-2020, 12:01 PM
Last Post: ndc85430
  logging: child module unable to get parent config jerryxiao 3 3,361 Apr-09-2019, 04:17 AM
Last Post: jerryxiao

Forum Jump:

User Panel Messages

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