.. 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']
<!-- 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']
Release files for dobject 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dobject-0.1.1.tar.gz | 2.0 kB | Details |
Release files / dobject-0.1.1.tar.gz
| Download URL | dobject-0.1.1.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77c8e4dea0eef1c70257d1ef7f4dfd693028ccf349e4b98822b14a109eddaf92
|
|
BLAKE2b-256 checksum How to use checksums |
4c45473ed4698e0223d40b75229848b3e5d7d6e8ba42786382111b0c0941fd58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |