Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Container():
- def __init__(self,list0,list1):
- self.list0,self.list1=list0,list1
- self.pairs=zip(list0,list1)
- self.items=dict(self.pairs)
- ...
- def __add__(self,key,value):
- dictionary=self.items
- other = other if type(other)==dict else other.items
- for k in other.keys():
- dictionary[k]=other[k]
- return dictionary
- ...
- def __iadd__(self,other):
- self.items=self+other
- # >>> c2 = Container([11,12,13],['k','l','m'])
- # >>> print container + c2
- # {0: 'j', 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 11: 'k', 12: 'l', 13: 'm'}
- #
- # Note: at this time the container does not equal None.
- #
- # >>> container+=c2
- # >>> print container
- # None
Add Comment
Please, Sign In to add comment