Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class list_wrapper(object):
- def __init__(self, items):
- self._items = items
- def __add__(self, items):
- return list_wrapper(self._items + items)
- def __repr__(self):
- return repr(self._items)
- def maybe_add_to_list(l, foo):
- l += foo
- l1 = [1, 2, 3]
- l2 = list_wrapper([1, 2, 3])
- maybe_add_to_list(l1, [4, 5, 6])
- maybe_add_to_list(l2, [4, 5, 6])
- print l1
- print l2
- # % python test.py
- # [1, 2, 3, 4, 5, 6]
- # [1, 2, 3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement