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

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.

Source Distribution

dobject-0.1.1.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file dobject-0.1.1.tar.gz.

File metadata

  • Download URL: dobject-0.1.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dobject-0.1.1.tar.gz
Algorithm Hash digest
SHA256 77c8e4dea0eef1c70257d1ef7f4dfd693028ccf349e4b98822b14a109eddaf92
MD5 d5697b7c251746f4a17f3fd1d4f1950e
BLAKE2b-256 4c45473ed4698e0223d40b75229848b3e5d7d6e8ba42786382111b0c0941fd58

See more details on using hashes here.

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