Completed
Push — develop ( 3606a5...c5328e )
by Kale
01:06
created

AttrDict.__init__()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 3
rs 10
1
# -*- coding: utf-8 -*-
2
"""Common collection classes."""
3
from __future__ import print_function, division, absolute_import
4
5
6
# http://stackoverflow.com/a/14620633/2127762
7
class AttrDict(dict):
8
    """Sub-classes dict, and further allows attribute-like access to dictionary items.
9
10
    Examples:
11
        >>> d = AttrDict({'a': 1})
12
        >>> d.a, d['a'], d.get('a')
13
        (1, 1, 1)
14
        >>> d.b = 2
15
        >>> d.b, d['b']
16
        (2, 2)
17
    """
18
    def __init__(self, *args, **kwargs):
19
        super(AttrDict, self).__init__(*args, **kwargs)
20
        self.__dict__ = self
21