Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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

Dobject
=======

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

Install
-------

.. code:: shell

pip install dobject

Usage
-----

.. 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.

Files for dobject, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size dobject-0.1.0.tar.gz (2.1 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