0

I have a configuration file in JSON format. This file is converted into a Python (3.8) Dict named config, which is a global variable. When I try to get the value from any of the keys and attempt to store them in a a variable called test I get the following error: 'NameError: name 'apiResponseOrder' is not defined'

I verified that the config variable is in fact a dict. (type check returns <class 'dict'>)

I am able to loop through the dict and print all the key-value pairs. The for loop prints values for the following keys: inputDir, outputDir, apiResponseOrder

def processHiscoreItem():
    print(type(config))

    for key, value in config.items():
        print(key)
        print(value)

    test = config.get(apiResponseOrder)
    print(test)

What is going wrong here? Why can I print the values of the keys, but cannot store them in the test variable?

2 Answers 2

2

test = config.get(apiResponseOrder) --> test = config.get('apiResponseOrder')

Sign up to request clarification or add additional context in comments.

Comments

0

apiResponseOrder is probably of str type, so you need to do this, instead

    test = config.get('apiResponseOrder')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.