Total Complexity | 1 |
Total Lines | 14 |
Duplicated Lines | 0 % |
1 | # -*- coding: utf-8 -*- |
||
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 |