attribute_dict
A subclass of dict that allows object-style access to its entries.
Installation
pipenv install attribute_dict
Usage
from attribute_dict import AttributeDict
sample_dict = AttributeDict({'foo': 'bar'})
sample_dict # => AttributeDict({'foo': 'bar'})
# The object is just subclassed from dict, and has all of the standard functions
isinstance(sample_dict, dict) # => True
# Create a new AttributeDict by "stacking" iterables
# Each iterable will overwrite keys in the previous one (kwargs are processed last!)
sample_dict = AttributeDict({'foo': 'foo'}, {'foo': 'ba', 'bar': 'foo'}, {'foo': 'bar'}, {'foobar': 'bar'}, foobar='foo')
# => AttributeDict({'foo': 'bar', 'bar': 'foo', 'foobar': 'foo'})
# Create a new AttributeDict by shallow-copying an existing one
new_sample_dict = sample_dict.copy()
new_sample_dict # => AttributeDict({'foo': 'bar', 'bar': 'foo', 'foobar': 'foo'})
isinstance(new_sample_dict, AttributeDict) # => True
# NOTE: Child values are NOT processed!
sample_dict = AttributeDict({'foo': iterable_two})
sample_dict # => AttributeDict({'foo': {'foo': 'ba', 'bar': 'foo'}})
sample_dict.foo # => {'foo': 'ba', 'bar': 'foo'}
sample_dict.__class__.__name__ # => 'AttributeDict'
sample_dict.foo.__class__.__name__ # => 'dict'
Tests
Tests use nose2. Clone the Github project. Install dev dependencies, and run tests using the nose2 command.
pipenv install --dev
pipenv shell
nose2
Release files for attribute-dict 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| attribute_dict-1.0.0.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| attribute_dict-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:12.0 kB
Release files / attribute_dict-1.0.0.tar.gz
| Download URL | attribute_dict-1.0.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd6c646a3803a0c2350e44c6e0cd193460d7fca18944675633d4882c1f0ab509
|
|
BLAKE2b-256 checksum How to use checksums |
1275f80f88f1c3deb460122685dd149bd26ee56d18463ea0f49c01c7f2fc9256
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1
|
Release files / attribute_dict-1.0.0-py3-none-any.whl
| Download URL | attribute_dict-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
205971dd6d418a0d03514bdf296099d6eb31795a9ac3189c5a646227f67074e7
|
|
BLAKE2b-256 checksum How to use checksums |
006373959ef6c40cd9f674bceb3c9d6087182ff57e58fc16c7568884757e0570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1
|