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,
        },
    }

```
What you have in your question looks like a Python dictionary. Since you want to know how one can return something like that, your question has two parts:

* the first part deals with [function usages](http://www.tutorialspoint.com/python/python_functions.htm)
* the second part deals with building up the [dictionary itself](http://learnpythonthehardway.org/book/ex39.html)

Luckily, these simple problems are well-documented and one can find the answer with smaller effort than by asking a question.