deepdiff icon indicating copy to clipboard operation
deepdiff copied to clipboard

not bug, but need help

Open sant527 opened this issue 2 years ago • 3 comments

This is not a bug

I want to know the key.

diff = deepdiff.DeepDiff(reverse_dict, paid_dict,verbose_level=1, view='tree')
print((diff.keys())
dict_keys(['type_changes', 'dictionary_item_removed', 'values_changed', 'dictionary_item_added'])
item = diff["values_changed"][0] 

print(item)
"<root['admin_fee'] t1:'-0.0', t2:'0.0'>"

now how to get the item key i.e 'admin_fee'

item.__dict__
{'t1': '-0.0',
 't2': '0.0',
 'down': None,
 'up': <root t1:{'admin_fee'...}, t2:{'accumulate...}>,
 'report_type': 'values_changed',
 'additional': {},
 't1_child_rel': None,
 't2_child_rel': None,
 '_path': {},
 'verbose_level': 1}

sant527 avatar May 24 '22 02:05 sant527

Do you mean item.keys() ?

Sep Dehpour

On May 23, 2022, at 7:14 PM, Santhosh Kumar @.***> wrote:

 This is not a bug

I want to know how to know the key

diff = deepdiff.DeepDiff(reverse_dict, paid_dict,verbose_level=1, view='tree') print((diff.keys()) dict_keys(['type_changes', 'dictionary_item_removed', 'values_changed', 'dictionary_item_added']) item = diff["values_changed"][0] now how to get the items key

item.dict {'t1': '-0.0', 't2': '0.0', 'down': None, 'up': <root t1:{'admin_fee'...}, t2:{'accumulate...}>, 'report_type': 'values_changed', 'additional': {}, 't1_child_rel': None, 't2_child_rel': None, '_path': {}, 'verbose_level': 1} — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

seperman avatar May 24 '22 03:05 seperman

here

item = diff["values_changed"][0]

print(item) "<root['admin_fee'] t1:'-0.0', t2:'0.0'>"

print(item.key) should print admin_fee

sant527 avatar May 24 '22 03:05 sant527

For getting the key, please take a look at path() function in https://zepworks.com/deepdiff/current/view.html#tree-view

Sep Dehpour

On May 23, 2022, at 8:48 PM, Santhosh Kumar @.***> wrote:

 here

item = diff["values_changed"][0]

print(item) "<root['admin_fee'] t1:'-0.0', t2:'0.0'>"

print(item.key) should print admin_fee

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

seperman avatar May 24 '22 16:05 seperman