DotIndex
Allows you to use dot notation to index dicts, like how you can in javascript
When printed, DotIndex objects are printed as a normal dict would be, however
the curly braces have a full stop before them, to signify that it is a
DotIndex object. (.{} would be an empty object)
Code Examples
Basic usage:
from DotIndex import DotIndex
x = {
"foo": "bar"
}
y = DotIndex(x)
print(y) # Expected output: ".{'foo': 'bar'}"
print(y.foo) # Expected output: "bar"
print(y["foo"]) # Expected output: "bar"
y["cat"] = "dog"
print(y.cat) # Expected output: "dog"
Adding together objects:
from DotIndex import DotIndex
x = DotIndex({
"foo": "bar"
})
y = DotIndex({
"cat": "dog"
})
# Adds all values in y to x
# Also works if you do `x = x + y`
x += y
print(x) # Expected output: ".{'cat': 'dog', 'foo': 'bar'}"
# Adding a DotIndex and a dict
z = x + {
"dicts": True
}
print(z) # Expected output: ".{'cat': 'dog', 'dicts': True, 'foo': 'bar'}"
# The second value overwrites any duplicate keys from the original object
z += {
"cat": "not dog"
}
print(z) # Expected output: ".{'cat': 'not dog', 'dicts': True, 'foo': 'bar'}"
Documentation
Creating the object
- Parameters
- obj (
dict[str, Any]) - the dict object that should be turned into a DotIndex object - recursive (
bool, default: True) - whether or not to DotIndex-ify any dicts inside the original object - verbose_logs (
bool, default: False) - whether or not to print out extra logs - ignore_errors (
bool, default: False) - whether or not to ignore non-critical errors
- obj (
- Other information:
- Keys in
objmust be strings, any other types will throw aTypeError(ignored withignore_errors) - Keys in
objcannot start with two underscores ("__") as those could be used to overwrite preexisting instance variables used for the class itself - If
recursiveis true, the values ofverbose_logsandignore_errorswill be passed through into any new DotIndex objects created
- Keys in
Converting types
iter(...)- Returns all keys in alphabetical orderstr(...)- Returns a string formatted like thestr(...)value of a dict object, with a full stop (".") at the start to show that it is a DotIndex type. Example:".{'foo': 'bar'}"repr(...)- Same asstr(...)int(...)- Returns the amount of keys in the objectfloat(...)- Same asint(...)except as a float typebool(...)- ReturnsTrueif there are any keys in the object, and if there aren't it returnsFalse
Comparisons
==- Checks if the two objects have all the values the same. Works with both DotIndex objects and dict objects!=- Opposite of==>,<,>=,<=- Compares the amount of keys in the object
Misc.
+- Takes the keys from the object on the right and adds them to the object on the left, overwriting any duplicateslen(...)- Returns the amount of keys in the object'val' in ...- Returns true if"val"is a key in the object
Metadata
Release files for DotIndex 1.1.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 | Provenance | Actions |
|---|---|---|---|---|
| DotIndex-1.1.0.tar.gz | 16.1 kB | Without provenance | Details for DotIndex-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| DotIndex-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for DotIndex-1.1.0-py3-none-any.whl |
Total release size: 32.4 kB
Release files / DotIndex-1.1.0.tar.gz
| Download URL | DotIndex-1.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f03fb651f13d116c68a63a0af341d9f5061cdc326e68fd83678470d4b0a2845c
|
|
BLAKE2b-256 checksum How to use checksums |
b1835b3d4e1a4b7f099c697d1d07cf8e51c16c31ea824fdc1e5e1012a569d7b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Release files / DotIndex-1.1.0-py3-none-any.whl
| Download URL | DotIndex-1.1.0-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5007c2621f57cbce2de8af325e9d0512d3a645f159f2eb53ed7e66a3a5ee99c
|
|
BLAKE2b-256 checksum How to use checksums |
c0a56ea3676240e60c8fddd1143ac6cc3bd6bf6a08d483400931b8d3938454cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Security for DotIndex 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.