'Get an attr by calling :meth:`dict.__getitem__`.
Like :meth:`__setattr__`, this method converts :exc:`KeyError` to
:exc:`AttributeError`.
Examples
>>> s = Struct(a=10)
>>> s.a
10
>>> type(s.get)
<... \'builtin_function_or_method\'>
>>> try:
...     s.b
... except AttributeError:
...     print("I don\'t have that key")
I don\'t have that key'

def __getattr__(self, key):

    try:
        result = self[key]
    except KeyError:
        raise AttributeError(key)
    else:
        return result
