Easy use dictionaries with specific features
Project description
All kind of dictionaries you always think but never do.
Instalation
To install dicts form Pypi:
easy_install dicts
or
pip install dicts
if you want to install it from source code:
python setup.py install
Usage
Dictionaries Features
join:
>>> d1 = Dict({1 : 7, 2 : [1,2], 3 : 'a'}) >>> d1.join({1 : 2, 2 : [3], 3 : 'b'}) {1: 9, 2: [1, 2, 3], 3: 'ab'}
fromrepetitions:
>>> Dict.fromrepetitions([1,1,1,1,2]) {1: 4, 2: 1}
Especific dictionaries
KeySortedDict:
>>> ksd = KeySortedDict({'c' : 1, 'a' : 6, 'b' : 5}) >>> ksd.items() [('a', 6), ('b', 5), ('c', 1)] >>> ksd.keys() ['a', 'b', 'c'] >>> ksd.values() [6, 5, 1]
ValueSortedDict
>>> vsd = ValueSortedDict({'c' : 1, 'a' : 6, 'b' : 5}) >>> vsd.items() [('c', 1), ('b', 5), ('a', 6)] >>> vsd.keys() ['c', 'b', 'a'] >>> vsd.values() [1, 5, 6]
SortedDict
>>> sd = SortedDict({'c' : (1,'b'), 'a' : (6,'c'), 'b' : (5,'a')}, key=lambda x: x[1][1]) >>> sd.items() [('b', (5, 'a')), ('c', (1, 'b')), ('a', (6, 'c'))]
NoCaseDict
>>> ncd = NoCaseDict({'examPLE' : 1}) >>> 'example' in ncd True
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
dicts-0.2.1.tar.gz
(5.7 kB
view details)
File details
Details for the file dicts-0.2.1.tar.gz
.
File metadata
- Download URL: dicts-0.2.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4de87e8f8e1cac585f85f3a99f035099c89fad3fee8f1d923a1ffa97a0c2b80 |
|
MD5 | 7ea63ec4daed732f48df8eb7dcc2cc50 |
|
BLAKE2b-256 | 724d1ddb2fa98e4ce350a410271d1a16bc33fe8dee47770c931338015e86e3fb |