Initialize with a dictionary, another Struct, or data. Parameters ---------- args : dict, Struct Initialize with one dict or Struct kw : dict Initialize with key, value pairs. Examples -------- >>> s = Struct(a=10,b=3
(self, *args, **kw)
| 39 | """ |
| 40 | _allownew = True |
| 41 | def __init__(self, *args, **kw): |
| 42 | """Initialize with a dictionary, another Struct, or data. |
| 43 | |
| 44 | Parameters |
| 45 | ---------- |
| 46 | args : dict, Struct |
| 47 | Initialize with one dict or Struct |
| 48 | kw : dict |
| 49 | Initialize with key, value pairs. |
| 50 | |
| 51 | Examples |
| 52 | -------- |
| 53 | |
| 54 | >>> s = Struct(a=10,b=30) |
| 55 | >>> s.a |
| 56 | 10 |
| 57 | >>> s.b |
| 58 | 30 |
| 59 | >>> s2 = Struct(s,c=30) |
| 60 | >>> sorted(s2.keys()) |
| 61 | ['a', 'b', 'c'] |
| 62 | """ |
| 63 | object.__setattr__(self, '_allownew', True) |
| 64 | dict.__init__(self, *args, **kw) |
| 65 | |
| 66 | def __setitem__(self, key, value): |
| 67 | """Set an item with check for allownew. |
nothing calls this directly
no test coverage detected