Skip to main content

DictDefaultNone

Get data from nested lists and dictionaries use Simple syntax, if can‘t return None, no raise IndexError or KeyError 用简单的python语法快速获取嵌套列表或者字典里的数据,如果没取到则返回空,而不是抛出IndexError或者KeyError

eg.: dict1["k1"]["k2"][0]["k"]

from ddn import DDN

data = {
    "data": [
        {
            "key1": "123",
            "key2": {
                "kkey1": {
                    "kkkey1": "1234",
                    "kkkey2": 12345
                }
            }
        },
        {
            "key1": "'1234'",
            "key3": {
                "kkey1": {
                    "kkkey1": "1234",
                    "kkkey2": True
                }
            }
        }
    ]
}

d = DDN(data)

if res1 := d['data'][1]["key3"]["kkey1"]['kkkey1']:  # '1234'
    print('ok', res1)
if not (res2 := d['data'][88]["user"]["username"]['firstname']):  # ''
    print('no', res2 + '1234')

print(DDN({13: 1}) + {23: 4})  # {13: 1, 23: 4}
print(DDN({13: 1}) + '123123', type(DDN({13: 1}) + '123123'))  # {13: 1}123123 <class 'str'>

Download files

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

Source Distribution

ddn-1.0.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

ddn-1.0.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file ddn-1.0.1.tar.gz.

File metadata

  • Download URL: ddn-1.0.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for ddn-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f76720945c5fb160b1a72609c73f041995c0c9949779ae7b29591c3c00ea9375
MD5 63681c29b35135bf9deb52128efb0a2c
BLAKE2b-256 77fa56e7082d649f2bb627bb72c6ec7f51a55cb441f537a4cfce031d0b279e81

See more details on using hashes here.

File details

Details for the file ddn-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ddn-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for ddn-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef7f8f8b02ab3cd217a95ca7e93d0520724bf525ab3d7af742d3e9112658a0ea
MD5 f97b063ca10e2a00a4f89d65f22f0def
BLAKE2b-256 09423fbe54ab386c0dbec24752898f7f8d05ef4255c715a661c1296dab26d387

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Supported by

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