[Tutor] critique my wrapper
Christopher Spears
cspears2002 at yahoo.com
Thu Feb 2 18:20:17 CET 2006
This is a class I created that wraps a list. Could
someone please critique the class?
class MyList:
def __init__(self, aList=None):
if aList is None:
self.mylist = []
else:
self.mylist = aList[:]
def __getitem__(self, index):
return self.mylist[index]
def __setitem__(self, index, value):
self.mylist[index] = value
def __len__(self):
return len(self.mylist)
def __delitem__(self, index):
del self.mylist[index]
def __add__(self, other):
self.mylist = self.mylist + other
def __repr__(self):
return '%s' % self.mylist
def append(self, other):
self.mylist.append(other)
def count(self, value):
return self.mylist.count(value)
def index(self, value):
return self.mylist.index(value)
def extend(self, seq):
self.mylist.extend(seq)
def insert(self, index, value):
self.mylist.insert(index, value)
def pop(self, index):
return self.mylist.pop(index)
def remove(self, value):
self.mylist.remove(value)
def reverse(self):
self.mylist.reverse()
def sort(self):
self.mylist.sort()
More information about the Tutor
mailing list