Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class myList(list):
- def myAppend(self, item):
- if isinstance(item, list):
- print 'Appending a list'
- self.append(item)
- elif isinstance(item, str):
- print 'Appending a string item'
- self.append(item)
- else:
- raise Exception
- L = myList()
- L.myAppend([1,2,3])
- L.myAppend('one two three')
- print L
- #Output:
- #Appending a list
- #Appending a string item
- #[[1, 2, 3], 'one two three']
Add Comment
Please, Sign In to add comment