Skip to main content

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 hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page