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

AttrDict   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %
Metric Value
dl 0
loc 14
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 3 1
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