Changeset 2551 for trunk/packages/invirt-base
- Timestamp:
- Nov 22, 2009, 4:07:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-base/python/invirt/common.py
r2541 r2551 13 13 def __init__(self, d = {}, __prefix = None, **kwargs): 14 14 'd is the dictionary or the items-iterable to update my __dict__ with.' 15 self.__dict__.update(d) 16 self.__dict__.update(kwargs) 15 dct = {} 16 dct.update(d) 17 dct.update(kwargs) 18 self.__dict__.update(dct) 19 self.__keys = set(dct) 17 20 self.__prefix = __prefix 18 21 def __getattr__(self, key): … … 25 28 raise AttributeError("anonymous struct has no member '%s'" 26 29 % (key,)) 30 def __iter__(self): 31 for i in self.__keys: 32 yield i 27 33 28 34 def dicts2struct(x, prefix = None): … … 119 125 self.assertEqual(structs.list[0], dicts['list'][0]) 120 126 self.assertEqual(structs.list[1].key, dicts['list'][1]['key']) 127 self.assertEqual(set(structs), set(['atom', 'dict', 'list'])) 121 128 122 129 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.