Conditions | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | 1 | from __future__ import absolute_import |
|
51 | 1 | def subset_dict(dictionary, keys): |
|
52 | """ |
||
53 | Restricts dictionary to only have keys from keys. Does not modify either |
||
54 | dictionary or keys, returning the result instead. |
||
55 | """ |
||
56 | |||
57 | 1 | result = dictionary.copy() |
|
58 | 1 | for original_key in dictionary: |
|
59 | 1 | if original_key not in keys: |
|
60 | 1 | del result[original_key] |
|
61 | |||
62 | return result |
||
63 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.