Question: How would I make Python return something like this:

```
{ "status": error,
  "location": loc,
  "codes": {
      "code1": 5,
      "code2": 6,
  },
}

```

I think this looks like a JSON object?

Answer: 
Literally, the answer to "how do I return this dict" is to *return this dict*:

```
def some_function():
    return {
        "status": error,
        "location": loc,
        "codes": {
            "code1": 5,
            "code2": 6,
        },
    }

```
If that is indeed a JSON object, you would want to use the JSON encoder/decoder that is part of the Python Standard Library. See [the official Python documentation](https://docs.python.org/3.5/library/json.html) for more information on it. It has a well-written basic usage section, and good examples.

That library, once imported, should allow you to have functions return JSON objects by using functions like `json.encode` and `json.default`.