Skip to main content

Tab completable ordered dictionary.

Project description

Introduction

The is a simplification and redesign of the orderedbunch package from tinytools. The package ontains an OrderedBunch object class with associated bunchify/unbunchify methods, similar to other bunch implementations but built off an OrderedDict with ipython table-complete overloaded to the data memebers. It removes the ordered_dictionarify function that is in tinytools and and leaves the development of the nested dictionaries to external code. The motivation is that it is quite complicated to infer what the user is wanting - and therefore error prone.

IPython has also recently changed its handling of the __dir__ method and it is unclear under which cases it is respected for tab completion or not. It seems, though, that for ipython 6, it is possible to remove mothods from the tab completion through the IPCompleter.* configuration options.

Installing

pip install orderedbunch

Import

import orderedbunch

Quick Start

from orderedbunch import OrderedBunch

## OrderedBunch
from collections import OrderedDict

# Create an OrderedBunch from and return it to an OrderedDict
od = OrderedDict({'a':1,'b':2,'c':{'aa':1.23,'bb':'string'}})
ob = orderedbunch.ordered_bunchify(od)
ob.a          # Explore the OrderdBunch with tab complete
ob['a']       # Equivalent to above
ob.c.bb       # orderd_bunchify is recursive on nested Dict objects
ob['c']['bb'] # Equivalent to above
od2 = tt.bunch.ordered_unbunchify(ob)

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

orderedbunch-1.0.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

orderedbunch-1.0.0-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page