Revision 1908
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/util.py | ||
---|---|---|
204 | 204 |
|
205 | 205 |
class NamedTuple: |
206 | 206 |
def __init__(self, **attrs): self.__dict__ = attrs |
207 |
|
|
208 |
def __iter__(self, **attrs): return iter(self.__dict__) |
|
209 |
|
|
210 |
def __getitem__(self, key): return getattr(self, key) |
Also available in: Unified diff
util.py: NamedTuple: Made it usable as a hashable dict (with string keys) by adding iter() and getitem()