Python Forum
name 'get_config' is not defined, config parser - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: name 'get_config' is not defined, config parser (/thread-12672.html)



name 'get_config' is not defined, config parser - zer0 - Sep-06-2018

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?


RE: name 'get_config' is not defined, config parser - Larz60+ - Sep-06-2018

do you mean config.get ?
there is no get_config