Skip to main content

Python dictionary with automatic and arbitrary levels of nestedness

Project description

jict

jict is basically a nested dict.
with some extra features

simple use example :

from jict import jict

jct = jict()
jct['level1']['level2']['level3'] = 'created nested dictionary'

print(jct)
# output :
# {
#   "level1": {
#     "level2": {
#       "level3": "created nested dictionary"
#     }
#   }
# }

# jict to dict
mydict = jct.dict()

jict utilities:

from jict import jict

# our jict
jct = jict({
    'val': { 'list':[ [{ 'find-me': 'secret' }] ] }
})

# we can easly find the key we need
print(jct.get('find-me'))

# we also can rename the keys
# output : secret
jct.rename('find-me','password')
print(jct.get('find-me'))
# output : None
print(jct.get('password'))
# output : secret

# we also can replace values
jct.replace('password','mypass')
print(jct.get('password'))
# output : mypass


def foo(val):
    val[0][0]['name'] = 'jict'
    return val

# we also can replace with callbacks and multiple values
jct.replace({
    'password':'mypass',
    'list': foo,
})

# callbacks also work with this: jct.replace('list' , foo)

print(jct.get('list'))
# output: [[{'password': 'mypass', 'name': 'jict'}]]

also you can easly load a .json , .yaml file

from jict import jict

jctj = jict('test.json')
print(jctj)
# output :
# {
#   "test": "json-content"
# }

jcty = jict('test.yaml')
print(jctj)
# output :
# {
#   "test": "yaml-content"
# }

# if you want to save the modifed values
jctj.save()
jcty.save()

# you can also save to another file
jcty.save('newfile.json')

also you can create a shared memory dict ( as sqlite3 instance )
and acces it from another process

from jict import jict

jct = jict('shm://mymemory')
jct['memoryfield'] = 'hi'


jct2 = jict('shm://mymemory')
print( jct2['memoryfield'] )
# output : hi

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

jict-2.2.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

jict-2.2.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file jict-2.2.2.tar.gz.

File metadata

  • Download URL: jict-2.2.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

File hashes

Hashes for jict-2.2.2.tar.gz
Algorithm Hash digest
SHA256 30349b6768696e365caca06cb735de50432975648181c24a5c56b3d42c80c5db
MD5 50952a05416f4c88e9e364ee90e99380
BLAKE2b-256 14acab9428efef8b8ef262d9bb6dbacaf8d70db6d4727536da47e871065d9465

See more details on using hashes here.

File details

Details for the file jict-2.2.2-py3-none-any.whl.

File metadata

  • Download URL: jict-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

File hashes

Hashes for jict-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfa1c73a81c20df78c069e0334c36cf60a32780dd657dc28942ec14502e61206
MD5 96ec6cb6c2fd182bbb0b3305091aca10
BLAKE2b-256 e2ab81c1c41cf985be22448bc860a26c9c71940bf7d400de3600582010718396

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