Better dictionary types for Python.
Project description
betterdicts
betterdict
from betterdicts import betterdict
Works just like a dict, but has some extra useful methods:
- invert()
- collate(it, type=list)
- filter(keys=None, values=None)
jsdict, njsdict, rjsdict
from betterdicts import jsdict, njsdict, rjsdict
These are betterdict
s but works like JavaScript object, where keys and
attributes are the same. This is accomplished with zero overhead.
These can be very convenient when working with parameters, configuration,
settings, or the like, where the obj['key']
or obj.get('key')
access method
feels a bit overly verbose for the simple task at hand.
number_dict
persistent_dict
The simplest possible persistent state exposed as a dict.
This is for when you need something really simple to store some flat data between script invocations, without the extra management of databases or file formats or the like.
Any change made directly to the dictionary[^1] causes it to save itself to disk as a pickle file. Whenever an instance is created of this dictionary it will load the same file.
The file defaults to cache.pickle
in the current working directory, but can be
specified as a parameter with persistent_dict(cache_file=<FILENAME>)
.
[^1]: "deep" changes like to objects stored in the dictionary are not tracked
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
Hashes for betterdicts-0.2.1.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53b3c5f16a72c28471b2f0c6b52e9d90048fd18fa05a5b112b87bec190bcb531 |
|
MD5 | 263965a2b446c39bfb2217fa0542c9d0 |
|
BLAKE2b-256 | 86c60c5b911a0bac790de36b1ec129ef530ec72cf0b76a0ff5d057e430461290 |