# Dixi - Deep Dictionaries for Python
## Installation
```bash
pip install dixi
```
## Examples
```python
from dixi import Dixi
data = Dixi({
'Chris': {
'age': 25,
'address': {
'city': 'Amsterdam',
'country': 'Netherlands',
},
},
'Anna': {
'age': 19,
'address': {
'city': 'Zürich',
'country': 'Switzerland',
},
},
'John': {
'age': 44,
'address': {
'city': 'London',
'country': 'United Kingdom',
},
},
})
```
### Deep indexing
```python
data['John', 'age']
# >> 44
```
### Partial indexing
```python
data['Chris', 'address']
# >> {'city': 'Amsterdam', 'country': 'Netherlands'}
```
### NumpPy style slicing
```python
data[:, 'address', 'country']
# >> Dixi({'Chris': 'Netherlands', 'Anna': 'Switzerland', 'John': 'United Kingdom'})
data[['Chris', 'Anna'], 'age']
# >> {'Chris': 25, 'Anna': 19}
```
### Setting
```python
data['Derek', 'hobbies'] = ['Sewing', 'Archery']
```
### Iteration
```python
for key in data: # or key in data.leafkeys()
print(key)
# >> ('Chris', 'age')
# >> ('Anna', 'age')
# >> ('Anna', 'address', 'city')
# >> ('Anna', 'address', 'country')
# >> ('John', 'age')
# >> ('John', 'address', 'city')
# >> ('John', 'address', 'country')
# >> ('Derek', 'hobbies')
```
```python
for key in data.keys():
print(key)
# >> Chris
# >> Anna
# >> John
# >> Derek
```
```python
for key, value in data.items():
print(key, value)
# >> Chris {'age': 25}
# >> Anna {'age': 19, 'address': {'city': 'Zürich', 'country': 'Switzerland'}}
# >> John {'age': 44, 'address': {'city': 'London', 'country': 'United Kingdom'}}
# >> Derek {'hobbies': ['Sewing', 'Archery']}
```
```python
data = Dixi({
0: { 0: 'a', 1: 'b' },
1: { 0: 'c', 1: 'd' },
})
for keys, value in data.iterleaves():
print(keys, value)
# >> (0, 0) a
# >> (0, 1) b
# >> (1, 0) c
# >> (1, 1) d
```
### Deletion
```python
del data['Chris', 'address']
```
## Todo
* Allow indexing for arrays
## Installation
```bash
pip install dixi
```
## Examples
```python
from dixi import Dixi
data = Dixi({
'Chris': {
'age': 25,
'address': {
'city': 'Amsterdam',
'country': 'Netherlands',
},
},
'Anna': {
'age': 19,
'address': {
'city': 'Zürich',
'country': 'Switzerland',
},
},
'John': {
'age': 44,
'address': {
'city': 'London',
'country': 'United Kingdom',
},
},
})
```
### Deep indexing
```python
data['John', 'age']
# >> 44
```
### Partial indexing
```python
data['Chris', 'address']
# >> {'city': 'Amsterdam', 'country': 'Netherlands'}
```
### NumpPy style slicing
```python
data[:, 'address', 'country']
# >> Dixi({'Chris': 'Netherlands', 'Anna': 'Switzerland', 'John': 'United Kingdom'})
data[['Chris', 'Anna'], 'age']
# >> {'Chris': 25, 'Anna': 19}
```
### Setting
```python
data['Derek', 'hobbies'] = ['Sewing', 'Archery']
```
### Iteration
```python
for key in data: # or key in data.leafkeys()
print(key)
# >> ('Chris', 'age')
# >> ('Anna', 'age')
# >> ('Anna', 'address', 'city')
# >> ('Anna', 'address', 'country')
# >> ('John', 'age')
# >> ('John', 'address', 'city')
# >> ('John', 'address', 'country')
# >> ('Derek', 'hobbies')
```
```python
for key in data.keys():
print(key)
# >> Chris
# >> Anna
# >> John
# >> Derek
```
```python
for key, value in data.items():
print(key, value)
# >> Chris {'age': 25}
# >> Anna {'age': 19, 'address': {'city': 'Zürich', 'country': 'Switzerland'}}
# >> John {'age': 44, 'address': {'city': 'London', 'country': 'United Kingdom'}}
# >> Derek {'hobbies': ['Sewing', 'Archery']}
```
```python
data = Dixi({
0: { 0: 'a', 1: 'b' },
1: { 0: 'c', 1: 'd' },
})
for keys, value in data.iterleaves():
print(keys, value)
# >> (0, 0) a
# >> (0, 1) b
# >> (1, 0) c
# >> (1, 1) d
```
### Deletion
```python
del data['Chris', 'address']
```
## Todo
* Allow indexing for arrays
Metadata
Release files for dixi 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dixi-0.0.1.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dixi-0.0.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 6.9 kB
Release files / dixi-0.0.1.tar.gz
| Download URL | dixi-0.0.1.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
881743375ef2fe1edca6fb235f956a3502ea58a035370c874be1846ea5c12e8e
|
|
BLAKE2b-256 checksum How to use checksums |
73f5b35d3e999a3409f9be6b7d17ba57edba4ef645f0140c463414411a4f668b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / dixi-0.0.1-py2-none-any.whl
| Download URL | dixi-0.0.1-py2-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
5850e25109418a32a1a9550a8111b7d32ce0e0261708048ab1ff72da199ecf57
|
|
BLAKE2b-256 checksum How to use checksums |
07c2907341c6a8796b2162026c0f663f93ab084d1c421f0e513b5e348e4e432a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |