Question: I have a script that reads a list of `users` and `reports` from a MySQL database and runs a function for each of the values. The script checks the db every 5 minutes and adds these value pairs to a dictionary. As I loop through I don't want to re-add value pairs that are still in the dictionary. I've had no issues handling that with this code:

```
if (user, report) not in t1.reports_to_call:
    t1.add(report, user)

```

My issue is that I want to also check a dictionary `t2.reports_requested` where the key is a tuple of three parts `user`, `report` and `some_unknown_id`. If there a way to run `not in` on a dictionary where you only know 2 of three elements and want to wildcard the third?

I have been also looking to see if I can refactor this secondary dictionary and move `some_unknown_id` out of the key as I do think it may be the case that the user/report pair is unique in this dictionary. But if I determine I need to wildcard the third value what is best way to do this?

```
{('user', 'report', 'some_unknown_id'): {}}

```

Answer: 
No, you cannot check for the existence of keys in a dict using wild-cards.

Make a dict of dicts:

```py
{('user', 'report'): {
    'some_unknown_id': {},
}

```

or even better:

```py
{'user': {
    'report': {
        'some_unknown_id' : {},
    },
}

```

Then you have the best of all worlds.

You can first check whether a user occurs, and if so, whether in combination with a report, and if so, whether in combination with some other identifier.
You can rely on the default `get` operation of the dictionary and add such element if `None` is returned as follow.

```py
if not t1.get((user, report), default=None):
    t1.add(report, user)

```

for the `t2`, I'd suggest to do a two level dictionary, sort of:

```py
t2 = {
    ('user', 'report'): {
        'some_unknown_id': {},
        'some_unknown_id_2': {},
    }
}

```

In that fashion you can handle several "third unkown keys" right under `('user', 'report')`.