Skip to main content

Open Kage's useful tools and class to public. (Long time used and upgraded) But, this is develope version. So, suddenly it will be big change when I got some more good idea. seperate to kDict from kmisc

Install

pip3 install kdic

Custom Dictionary Class

Convert Dictionary to Object style Dictionary

Contents

  1. Create tree type items
  2. Added New commands
    1. Put() : Put value at a item
    2. Get() : Get value of item
    3. Del() : Delete item
    4. Update() : Update value at item
    5. Print() : Print dictionary
    6. Diff() : Compare two dictionary
    7. Check() : Check put the value is same as the item(key)'s value
    8. List() : Return list of keys value
    9. Proper() : Show/Set/Update property at the item.
    10. Find() : Find data in the dictionary
    11. Load() : Load saved data from file
    12. Save() : dictionary save to file
    13. Sort() : Sort dictionary
    14. FirstKey(): Get first Key
    15. FirstKey(): Get first Key
  3. Added property at each key
  • Initialize dictionary
import kDict
root=kDict.kDict()
import kDict
>>> test={
      'a':123,
      'b':{
         'c':{'ddd'},
         'e':{}
      }
    }
root=kDict.kDict(test)
  • Add new data
>>> root.tree.apple.color='red'

or

>>> root.tree.apple.Put('color','red')

or

>>> root.tree.apple['color']='red'
  • Get data
>>> root.tree.apple.color.Get()

or

>>> root.tree.apple.Get('color')
  • Print dictionary
>>> root.Print()
>>> root.tree.Print()
  • Set property at Apple's color

    • Set readonly
>>> root.tree.apple.color.Proper('readonly',True)
  • Try change data
>>> root.tree.apple.Put('color','white')
item is readonly

>>> root.tree.Print()
{'color': {'._d': 'red', '._p': {'readonly': True}}}
  • Unset readonly
>>> root.tree.apple.color.Proper('readonly',False)
  • Try change data
>>> root.tree.apple.Put('color','white')
>>> root.tree.Print()
{'color': {'._d': 'red', '._p': {'readonly': True}}}

Sample Dictionary:

{'a': 123,
 'b': {'c': set(['ddd']), 'e': {}, 'z': 123},
 'tree': {'apple': {'color': {'._d': 'white', '._p': {'readonly': False}}},
          'banana': {'banana2': {'._d': 'white', '._p': {}},
                     'banana3': {'._d': 'yellow', '._p': {}},
                     'color': {'._d': 'yellow', '._p': {'readonly': True}}},
          'yellow': {'monkey': {'._d': 'white', '._p': {}}}}}
  • Find readonly property item path
>>> root.Find('readonly',property=True)
['tree/banana/color']
  • Find apple key path
>>> root.Find('apple',mode='key')
['tree/apple']
  • Find white color data path
>>> root.Find('white')
['tree/apple/color', 'tree/yellow/monkey', 'tree/banana/banana2']
  • Find 123 data path
>>> root.Find('white')
['a', 'b/z']
  • Find white color data path in key and value
>>> root.Find('yellow',mode='all')
['tree/yellow', 'tree/banana/color', 'tree/banana/banana3']
  • Save Data (always use root if not then save partial data)
>>> import kDict
>>> kDict.kDict._dfile_='<dict file name>'
>>> root=kDict.kDict()
>>> root.Save()
  • Load Data (always use root if not then load at key)
>>> import kDict
>>> kDict.kDict._dfile_='<dict file name>'
>>> root=kDict.kDict()
>>> root.Load()

Release files for kdic 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kdic 1.0.10
File Size Uploaded
kdic-1.0.10.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kdic 1.0.10
File Interpreter ABI Platform
kdic-1.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / kdic-1.0.10.tar.gz

Download URL kdic-1.0.10.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b0edd5b37d69578b724109b094d695e311193e96aa7fb504ffaf85e682c15769
BLAKE2b-256 checksum
How to use checksums
5fc15df687b016097431fb29d5a7584cb861800823c5b6223d6587802bef2951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release files / kdic-1.0.10-py3-none-any.whl

Download URL kdic-1.0.10-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90f7f954d944aa2b5618bcd857df4338c28f37e5eb9e4a3f8256368f11eb25f0
BLAKE2b-256 checksum
How to use checksums
ea471ec972ab152516cd73456e96885e011a9099c621776e4a2cd21402aa3dff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.0.10 This release

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.5

2 release files

1.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page