Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 1 | def iter_items(keys, dict): |
2 | """Iterator over keys and yeilds items from dict. | ||||
3 | |||||
4 | Iterates over keys and yeilds tuples of a key and a value only if key is | ||||
5 | presented in dict. | ||||
6 | |||||
7 | :param keys: A list of keys to iterate over. | ||||
8 | :param dict: A dict to iterate over. | ||||
9 | """ | ||||
10 | for key in keys: | ||||
11 | if key in dict: | ||||
12 | yield (key, dict[key]) |