Skip to main content

A simple diff tool for dictionary and list

Project description

simple_diff

A simple diff tool for dictionary and list

>>> import simple_diff
>>> old_dict = {'a':1, 'b':2, 'c':3, 'd':4}
>>> new_dict = {'b':1, 'c':3, 'd':4, 'e':5}    
>>> 
>>> simple_diff.dict_diff(old_dict, new_dict)
{
  'created': [{'key': 'e', 'value': 5}], 
  'deleted': [{'key': 'a', 'value': 1}], 
  'unchanged': [{'key': 'd', 'value': 4}, {'key': 'c', 'value': 3}], 
  'modified': [{'old': {'key': 'b', 'value': 2}, 'new': {'key': 'b', 'value': 1}}]
}
>>> 
>>> old_list = [{'index':1, 'name': 'bob'}, {'index':2, 'name': 'john'}, {'index':3, 'name': 'tom'}]
>>> new_list = [{'index':2, 'name': 'john'}, {'index':3, 'name': 'kevin'}, {'index':4, 'name': 'mary'}]
>>> simple_diff.list_diff(old_list, new_list, key= 'index')             
{
  'created': [{'index': 4, 'name': 'mary'}], 
  'deleted': [{'index': 1, 'name': 'bob'}], 
  'unchanged': [{'index': 2, 'name': 'john'}], 
  'modified': [{'old': {'index': 3, 'name': 'tom'}, 'new': {'index': 3, 'name': 'kevin'}}]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple-diff-0.1.0.tar.gz (1.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_diff-0.1.0-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file simple-diff-0.1.0.tar.gz.

File metadata

  • Download URL: simple-diff-0.1.0.tar.gz
  • Upload date:
  • Size: 1.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.2

File hashes

Hashes for simple-diff-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22eee6e772814942af5fddd05196b6b477af77b1df5928619bdba7af134fe0b7
MD5 5d68d456ceebc0c87fc1acf864d4a561
BLAKE2b-256 71fd08bf9c8da99db3280862b3ed27152d17b882b35ba54d074ba1c6ee11533d

See more details on using hashes here.

File details

Details for the file simple_diff-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: simple_diff-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.2

File hashes

Hashes for simple_diff-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a87b54cd0bc3ac008fa8870117a43702febfe025700adf16528ba87fe8586203
MD5 a1789ec294231f620c9431209c88c589
BLAKE2b-256 8f7207cc257171edd03da35cce0af3516314629c42e3722741871bd1cef7a4e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page