Advertisement
furas

Python - challange "list without list"

Jun 1st, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.53 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. # Challaneg on Facebook in group Python Programming Language
  4. # https://www.facebook.com/groups/python.programmers/permalink/2136776633006808/
  5.  
  6. class MyList:
  7.    
  8.     def __init__(self, data=None):
  9.         raise NotImplementedError('You have to implement MyList.__init__()')
  10.  
  11.     def __str__(self):
  12.         raise NotImplementedError('You have to implement MyList.__str__()')
  13.  
  14.     def __len__(self):
  15.         raise NotImplementedError('You have to implement MyList.__len__()')
  16.  
  17.     def __getitem__(self, key):
  18.         raise NotImplementedError('You have to implement MyList.__getitem__()')
  19.  
  20.     def __setitem__(self, key, value):
  21.         raise NotImplementedError('You have to implement MyList.__setitem__()')
  22.  
  23.     def __in__(self, value):
  24.         raise NotImplementedError('You have to implement MyList.__in__()')
  25.  
  26.     def __add__(self, value):
  27.         raise NotImplementedError('You have to implement MyList.__add__()')
  28.  
  29.     def __radd__(self, value):
  30.         raise NotImplementedError('You have to implement MyList.__radd__()')
  31.  
  32.     def __iter__(self):
  33.         raise NotImplementedError('You have to implement MyList.__iter__()')
  34.  
  35.     def __next__(self):
  36.         raise NotImplementedError('You have to implement MyList.__next__()')
  37.  
  38.     def append(self, data):
  39.         raise NotImplementedError('You have to implement MyList.append()')
  40.  
  41.     def expand(self, data):
  42.         raise NotImplementedError('You have to implement MyList.expand()')
  43.  
  44.     def contains(self, value):
  45.         raise NotImplementedError('You have to implement MyList.contains()')
  46.  
  47.     def find(self, value):
  48.         raise NotImplementedError('You have to implement MyList.find()')
  49.  
  50. # ----
  51.  
  52. #m = MyList()    # error: You have to implement MyList.__init__()
  53. #print(m)        # error: You have to implement MyList.__str__()
  54. #len(m)          # error: You have to implement MyList.__len__()
  55. #m[0]            # error: You have to implement MyList.__getitem__()
  56. #m[0:1]          # error: You have to implement MyList.__getitem__()
  57. #m[0] = 1        # error: You have to implement MyList.__setitem__()
  58. #m[0] = m[0] + 1 # error: You have to implement MyList.__getitem__() and MyList.__setitem__()
  59. #for x in m:     # error: You have to implement MyList.__iter__() (and MyList.__next__())
  60. #1 in m          # error: You have to implement MyList.__in__()
  61. #m.append(1)     # error: You have to implement MyList.append()
  62. #m.expand([1,2]) # error: You have to implement MyList.expand()
  63. #m.contains(1)   # error: You have to implement MyList.contain()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement