0

I am using json.load() to read a json config file into a dictionary, but I couldn't use is keyword for comparing string values.

config = json.load(open(config_file))
if config['some_key'] is 'abc':
# code block

even the value of config['some_key'] is abc, the if block is passed somehow. But if I changed the code to,

if config['some_key'] == 'abc':
# code block

the if code body will get executed. I am wondering what is the issue. Since string is a python object, so should be no problem using is for value comparison.

daiyue
  • 7,196
  • 25
  • 82
  • 149

0 Answers0