Skip to main content

Dictionary Navigator With Strings

Project description

Python Dictionary Navigator

Quick Start

To install, use pip:

pip install -U dictionay_navigator

Usage

>>> from dictionary_navigator import navigator
>>> myDict = {
        'person': {
            'name': {
                'first': 'Michael',
                'las': 'Scott'
            },
            'height': 175.3,
            'friendsNames': ['Jim', 'Ryan', 'Todd', 'Stanley', 'Darryl'],
            'enemies': ['Toby']
        }
    }

>>> navigator.navigate(myDict, 'person.name.first')
'Michael'

>>> navigator.navigate(myDict, 'person.friendsNames')
['Jim', 'Ryan', 'Todd', 'Stanley', 'Darryl']

>>> navigator.navigate(myDict, 'person.friendsNames[2]')
'Todd'

>>> navigator.navigate(myDict, 'person.friendsNames[10]')

>>> navigator.navigate(myDict, 'person.friendsNames[10]', default='Dwight')
'Dwight'

>>> navigator.navigate(myDict, 'person.friendsNames[10]', safeNavigation=False)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "testProject/.pyenv/local/lib/python2.7/site-packages/dictionary_navigator/navigator.py", line 35, in navigate
    currentObject = currentObject[index]
IndexError: list index out of range

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dictionary-navigator, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size dictionary_navigator-1.0.1-py2-none-any.whl (7.6 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size dictionary_navigator-1.0.1.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page