Advertisement
treyhunner

* and ** example

Feb 23rd, 2016
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. class D:
  2.     contents = ['a', 'b', 'c']
  3.     def __getitem__(self, x):
  4.         return self.contents[x]
  5.     def __contains__(self, key):
  6.         return key in self.keys()
  7.     def keys(self):
  8.         return range(len(self.contents))
  9.  
  10.  
  11. assert {**D()} == {0: 'a', 1: 'b', 2: 'c'}
  12. assert [*D()] == ['a', 'b', 'c']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement