Skip to main content

Dictionary to object tools

Project description

.. raw:: html

<!-- starttoc -->

Table of contents

- `Dobject <#dobject>`__

- `Install <#install>`__
- `Usage <#usage>`__

- `Access all the dictionary keys like object
attributes <#access-all-the-dictionary-keys-like-object-attributes>`__

.. raw:: html

<!-- endtoc -->


Easily convert dicts to objects. Access key values as object attributes.


.. code:: shell

pip install dobject


.. code:: python

from dobject import DObject
import datetime

dict_data = {'data': [{'effective_date': datetime.datetime(2017, 3, 2, 0, 0),
'new_symbol': 'MOMENT',
'old_symbol': '2E'},
{'effective_date': datetime.datetime(2017, 4, 27, 0, 0),
'new_symbol': 'AAAG',
'old_symbol': 'AAAGE'},
{'effective_date': datetime.datetime(2016, 11, 30, 0, 0),
'new_symbol': 'PIOI',
'old_symbol': 'ACPW'}],
'ticker_changes': [{'new_symbol': 'MOMENT', 'old_symbol': '2E'},
{'new_symbol': 'AAAG', 'old_symbol': 'AAAGE'},
{'new_symbol': 'PIOI', 'old_symbol': 'ACPW'}]}

obj = DObject(dict_data)

# Access all the dictionary keys like object attributes
print obj.ticker_changes[0].old_symbol

You could also access the values like you would with a dictionary.

.. code:: python

print obj['ticker_changes'][0]['old_symbol']

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
dobject-0.1.1.tar.gz (2.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page