Skip to main content

借鉴 pathlib.Path 链式操作方式,简化深字典的操作。

Project description

PathLikeDict

借鉴 pathlib.Path 链式操作方式,简化深字典的操作。

安装

使用以下命令安装:

pip install PathLikeDict

使用

import DeepDict

adict = {}
bdict = DeepDict(adict).path('a.b.c').set('d', 1).path(['e', 'f']).set('g', 2)
print(adict)
print(bdict)
# {'a': {'b': {'c': {'d': 1, 'e': {'f': {'g': 2}}}}}}
# {'g': 2}

bdict.path('wow').set(['a', 'b', 'c'], [3, 4, 5])
print(adict)
print(bdict)
# {'a': {'b': {'c': {'d': 1, 'e': {'f': {'g': 2, 'wow': {'a': 3, 'b': 4, 'c': 5}}}}}}}     
# {'a': 3, 'b': 4, 'c': 5}

贡献

欢迎提交 pull request 来改进 PathLikeDict。

许可

MIT

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

PathLikeDict-0.0.4.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file PathLikeDict-0.0.4.tar.gz.

File metadata

  • Download URL: PathLikeDict-0.0.4.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for PathLikeDict-0.0.4.tar.gz
Algorithm Hash digest
SHA256 04c86775021b9caea057e9a543f7b0bb668ef3730f6cfaff8adaf94f2be64c15
MD5 069ee45c0d29965466a7f036ba8c8e79
BLAKE2b-256 a61f51431503ec3706ef08602b8b72e6aa79c852e0838dba7a46681ceca361b5

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