I have a request with JSON data, it may or may not contain `'items'` key, if it does it has to be a list of objects, that I want to process individually. So I have to write something like:

```
json_data = request.get_json()
for item in json_data['items']:
    process_item(item)

```

But, since presence of the `'items'` key is not mandatory, an additional measure needs to be taken. I would like to follow [EAFP](https://docs.python.org/2.7/glossary.html#term-eafp) approach, so wrapping it up into `try ... except` statement:

```
json_data = request.get_json()
try:
    for item in json_data['items']:
        process_item(item)
except KeyError as e:
    pass

```

Let's assume that a `KeyError` exception can happened inside the `process_item(...)` function, that may indicate a code error, thus it should not go unnoticed, so I want to make sure that I will catch only exceptions coming from `for` statement predicate, as a workaround I came up with:

```
json_data = request.get_json()
try:
    for item in json_data['items']:
        process_item(item)
except KeyError as e:
    if e.message != 'items':
        raise e
    pass

```

But 

1. It looks ugly
2. It relies on knowledge of the `process_item(...)` implementation, assuming that `KeyError('items')` cannot be raised inside of it.
3. If the `for` statement becomes more complex e.g. `for json_data['raw']['items']` so will the `except` clause making it even less readable and maintainable.

**Update:**
The suggested alternative 

```
json_data = request.get_json()
try:
    items = json_data["items"]
except KeyError:
    items = []

for item in items:
    process_item(item)

```

is essentially the same as 

```
json_data = request.get_json()
if json_data.has('items')
    items = json_data['items']
else:
    items = []

for item in items:
    process_item(item)

```

So we check before we loop. I would like to know if there is any more pythonic/EAFP approach?