Error in Python when using JSON.Load : name 'isinstance' is not defined

874 Views Asked by At

Python noob here. I'm trying to execute a Python script but on json.load it fails with the error message name 'isinstance' is not defined.

Since json is a library that comes with the Python installation (3.4.2) I find this very strange. Has anyone encountered anything similar and/or may have a solution?

The code looks like this

try:
    prefs_path = os.path.join(os.path.expanduser("~"), ".foo")
    prefs_file = open(prefs_path)
    prefs_hash = json.load(prefs_file)
except Exception as e:
    raise Exception(str(e))
1

There are 1 best solutions below

0
On

Thanks guys! Yea, it actually came up that something was wrong in the file I was trying to read. Once I edited it and fixed the problem the Python script works.

Funny tho how a typo in the json file would cause such an error, complaining about isinstance()!