Guest User

Untitled

a guest
Jun 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class myList(list):
  2. def myAppend(self, item):
  3. if isinstance(item, list):
  4. print 'Appending a list'
  5. self.append(item)
  6. elif isinstance(item, str):
  7. print 'Appending a string item'
  8. self.append(item)
  9. else:
  10. raise Exception
  11.  
  12. L = myList()
  13. L.myAppend([1,2,3])
  14. L.myAppend('one two three')
  15. print L
  16.  
  17. #Output:
  18. #Appending a list
  19. #Appending a string item
  20. #[[1, 2, 3], 'one two three']
Add Comment
Please, Sign In to add comment