Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> class dict_(dict):
- def append(self,*args):
- for arg in args:
- if arg and type(arg)==dict:
- for i in arg.iteritems():
- key = i[0]
- value = i[1]
- self[key] = value
- else:
- raise Exception("Not a dictionary.")
- >>> x = dict_({4:3})
- >>> x.append(5)
- Traceback (most recent call last):
- File "<pyshell#136>", line 1, in <module>
- x.append(5)
- File "<pyshell#134>", line 10, in append
- raise Exception("Not a dictionary.")
- Exception: Not a dictionary.
- >>> x.append({11:11},{12:12})
- >>> x
- {12: 12, 11: 11, 4: 3}
- >>> x.append({433:23,223:12})
- >>> x
- {12: 12, 11: 11, 4: 3, 223: 12, 433: 23}
Advertisement
Add Comment
Please, Sign In to add comment