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'}
map:
>>> d = Dict({'1' : 1, '2' : 2}) >>> d.map(lambda x: 1/3.0) >>> d {'1': 0.3333333333333333, '2': 0.3333333333333333}
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.2.tar.gz
(5.8 kB
view details)
File details
Details for the file dicts-0.2.2.tar.gz
.
File metadata
- Download URL: dicts-0.2.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3c3142b6d12bb174d583f2ff4184700c1071f63155ecc7d237297ddd641fb8c |
|
MD5 | de01011ebd4761e853506a2ceee308b4 |
|
BLAKE2b-256 | c9b1a9eaacf014e09e7d2090c6380c88392ffbc5617b6fe8a8009e240778e5f4 |