[PYTHON] Access to dictionary fields

Hello. If you look at "A better Python object for JSON take 2" , It was written about how to access dictionary values (you can access it as in the source below). A similar one has been made and seems to have been a hot topic for a long time:

  1. Dot access to fields instead of []
>>> from easydict import EasyDict as edict
>>> x = edict({'cos':1})
>>> x
{'cos': 1}
>>> x['cos']
1
>>> x.cos
1
>>> x['sin']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'sin'
>>> x.sin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'EasyDict' object has no attribute 'sin'

Recommended Posts

Access to dictionary fields
How to use dictionary {}
Introduction to dictionary lookup algorithm
Add a dictionary to MeCab
Add user dictionary to MeCab
Subscript access to python numpy array
Add fields to features with ArcPy
How to access wikipedia from python
How to access environment variables in Python
Convert Python> two value sequence to dictionary
[Django] Convert QuerySet to dictionary type list
Three ways to access the __main__ namespace
How to access RDS from Lambda (python)
[Introduction to Udemy Python3 + Application] 24. Dictionary type
How to access the Datastore from the outside
Script to create a Mac dictionary file
[Introduction to Udemy Python3 + Application] 61. Dictionary comprehension