This repository has been archived by the owner on Jan 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
DictObject
Christian Cuevas edited this page Apr 26, 2017
·
16 revisions
DictObject is a class within gamelocker which converts a python dictionary into a object.
>>> gamelocker.DictObject(dictionary)
>>> api = gamelocker.Vainglory(vg_api_key) # Create the instance of the class<br>
>>> data = api.dict_to_object(dictionary) # Convert a dictionary to a object
The DictObject class would turn the following dictionary into an object:
>>> {"id": "123456789", "name": "ClarkthyLord", "region": "na", "titles": ["developer", "creator"], "extra": {"likes": "vainglory", "dislikes": "pain"}}
Tired of having to type ["key_name"] every time you want to retrieve data from a dictionary?
Then the DictObject class is perfect for you! Turning that dictionary into an object can save you the trouble of typing the [""]
- Before
>>> data["name"]
- After
>>> data.name
- Before
>>> data["titles"][1]
- After
>>> data.titles[1]
- Before
>>> data["extra"]["likes"]
- After
>>> data.extra["likes"]
DictObject is still in testing; use at your own risk!