Skip to content

Commit 9af936f

Browse files
author
Kenneth Reitz
committed
key_differ
1 parent 183710a commit 9af936f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

github3/helpers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ def is_collection(obj):
2525
return val
2626

2727

28+
def key_diff(source, update):
29+
"""Given two dictionaries, returns a list of the changed keys."""
30+
31+
source = dict(source)
32+
update = dict(update)
33+
34+
changed = []
35+
36+
for (k, v) in source.items():
37+
u_v = update.get(k)
38+
39+
if (v != u_v) and (u_v is not None):
40+
changed.append(k)
41+
42+
return changed
43+
44+
2845
# from arc90/python-readability-api
2946
def to_python(obj,
3047
in_dict,

0 commit comments

Comments
 (0)