Project

General

Profile

« Previous | Next » 

Revision 1908

util.py: NamedTuple: Made it usable as a hashable dict (with string keys) by adding iter() and getitem()

View differences:

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