Skip to main content

No project description provided

Project description

Documentation Status

Logo

Hiker

Navigating nested python objects with ease.

This package ships a lot of functionality you might recognise from python's dict or list methods, like getters and setters, the update function and the likes, but for nested objects consiting of dicts and lists. You can specify what part of you nested object you want by using a '/deep/path/syntax/' and can update only branches of your objects without overwriting of deleting unspecified paths.

The basis for all this is the walk function. It accepts your nested object and calls a function on all leaf variables.

Example

dol = {'a': [1, 2], 'b': {'c': 3, 'd': 4}}

def fn(val):
    return val**2

result = walk(dol, fn)
print(result)  # {'a': [1, 4], 'b': {'c': 9, 'd': 16}}
print(dol)  # {'a': [1, 2], 'b': {'c': 3, 'd': 4}}

result = walk(dol, fn, inplace=True)
print(result)  # {'a': [1, 4], 'b': {'c': 9, 'd': 16}}
print(dol)  # {'a': [1, 4], 'b': {'c': 9, 'd': 16}}

Below you can find a table which compares hiker's functionality with those of python's dict and list.

hiker dict list Example
walk - -
retrieve dict[key], dict.get() list[index] retrieve({'a': [1, 2]}, 'a/0]) => 1
pop_keypath dict.pop() list.pop
set_default dict.setdefault()
set_value dict[key] = val, list[index] = val
contains_key key in dict 0 <= index < len(list)
update dict.update()
get_lead_names dict.keys()

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

hiker-0.1.2.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file hiker-0.1.2.tar.gz.

File metadata

  • Download URL: hiker-0.1.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for hiker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c2a37a6472f8c5474ca092d764dd312635e246b7962f3592dd8aef05b511fdee
MD5 a697c55ddf9f0631f4ae0159d99cdc18
BLAKE2b-256 743c62ce4c2b9686cb53c10ac462cc94efad5af279ba9d56d516a51149a07cd1

See more details on using hashes here.

Supported by

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