Skip to main content

Dictionary class with advanced functionality

Project description

what-a-dict

Dictionary class with advanced functionality

Installation

Make sure your are using the up-to-date version of pip

pip install --upgrade pip

Then install the package

pip install what-a-dict

Usage

import the class first

from wad import Dict

Instance Creation

Use it as a dictionary class with string keyword arguments:

# style1
members=Dict(name="SYHuang",
             discriptions="Please Subscribe")
# style2
d={"name":"SYHuang",
    "discriptions":"Please Subscribe"}
members=Dict(**d)

It is also allowed to create instance of Dict which value of traditional dict or Dict

# style1
members=Dict(
    friends={
        "ge62":"computer",
        "iphone":"phone"})
# style2
members=Dict(
    friends=Dict(
        ge62="computer",
        iphone="phone"))

Usage

Items can be get as in a dict

members["friend"]

The keys are also the attribute of this object

members.friend

other functions like iteration, update are the same as in dict:

# update (you can put in a hybrid with "dict"s and "Dict"s)
members.update({"friends":Dict(ge62="good computer")})

# iteration
for k,v in members.items():
    pass

# concatenation
members_new=Dict(members,**{"friends":Dict(ge62="good computer")})
###

I provided a way of pretty print FYI:

members.repr_()
# print out:
- layer1 key1: value
- layer1 key2(if it is a list/tuple): value[0] * (lenth of the list/tuple)
- layer1 key3(if it is a Dict):
    - layer2 ke1{a Dict}:
        - layer3 ke1: value

(Example showing for iterable objects can be further extend to numpy array or other tensors, to be discussed)

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

what-a-dict-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

what_a_dict-0.1.1-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file what-a-dict-0.1.1.tar.gz.

File metadata

  • Download URL: what-a-dict-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.2 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.10

File hashes

Hashes for what-a-dict-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d4db633e7eea8978b26ed412cc1d1a5864f1d315edb8ae7ec0c3c487977529fe
MD5 9aec900762dd4c967347f798fef4d22f
BLAKE2b-256 c642d2d306851c63e9666f6a5624c27b127585c02c2b9b779c077f35f8724ccb

See more details on using hashes here.

File details

Details for the file what_a_dict-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: what_a_dict-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.2 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.10

File hashes

Hashes for what_a_dict-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3f1a094ecd70a5546b96dd98b08bd48eca2dceaf66fbc0f62cdf849b1767a2c0
MD5 865ed8f39b8e8aac3b4b89ba63681195
BLAKE2b-256 aec97a11e39faa7b80bfde623d91c1bdb1c334beed03f25633134ff9277ede64

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