Dictator is a tiny library for Robots to work with Redis as a Dict.
Project description
Dictator is a tiny library for Robots to work with Redis as a Dict.
It handles Redis API commands and represent itself as a dict-like object.
Install
$ pip install dictator
Usage
It’s easy to start by creating Dictator object
>>> dc = Dictator(host='localhost', port=6379, db=0)
For the moment it handles not all features of Python Dict but basics:
.set(key, value)
>>> dc.set('Planets', ['Mercury', 'Venus', 'Earth']) >>> dc['Stars'] = ['Sun']
.get(key)
>>> dc['Stars'] ['Sun'] >>> dc.get('Planets') ['Mercury', 'Venus', 'Earth']
You can set default value for get() function just like for a dict-object:
>>> dc.get('Comets', 'No data') 'No data'
.pop(key, default=None)
>>> dc.pop('Stars') ['Sun'] >>> dc.pop('Comets')
.delete(key)
>>> dc.delete('Comets')
or
>>> del dc['Comets']
.keys() and .values()
>>> dc.keys() ['Planets', 'Stars'] >>> dc.values() [['Mercury', 'Venus', 'Earth']]
.items()
>>> dc.iterms() [('Planets', ['Mercury', 'Venus', 'Earth'])]
also it supports iteration via generator object:
.iterkeys()
.itervalues()
.iteritems()
and a bit more!
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
dictator-0.1.tar.gz
(2.8 kB
view details)
File details
Details for the file dictator-0.1.tar.gz
.
File metadata
- Download URL: dictator-0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79cf68c6b18ba6248224ad33a5c34d47a1c3a7c0bf32b6679cd28cdaff773efa |
|
MD5 | 921627499e45a5551448fdb68afa831b |
|
BLAKE2b-256 | 5e384f168b8df24fa8a298e44d0b8728fb2a6eaec9b94eed0e4f71897fc0430b |