summaryrefslogtreecommitdiffstats
path: root/Lib/dos-8x3/userlist.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-04-08 20:27:54 (GMT)
committerGuido van Rossum <guido@python.org>1999-04-08 20:27:54 (GMT)
commit9a744a9dd771ee8997bdebaf47ff999b5adc9733 (patch)
tree5060172f273b17409371c9ad1441b2a8bbc315be /Lib/dos-8x3/userlist.py
parent6d0de99d8da806798ce0b896159bd07fce71c0dc (diff)
downloadcpython-9a744a9dd771ee8997bdebaf47ff999b5adc9733.zip
cpython-9a744a9dd771ee8997bdebaf47ff999b5adc9733.tar.gz
cpython-9a744a9dd771ee8997bdebaf47ff999b5adc9733.tar.bz2
The usual
Diffstat (limited to 'Lib/dos-8x3/userlist.py')
-rwxr-xr-xLib/dos-8x3/userlist.py112
1 files changed, 63 insertions, 49 deletions
diff --git a/Lib/dos-8x3/userlist.py b/Lib/dos-8x3/userlist.py
index 93e4a7e..a60d8ce 100755
--- a/Lib/dos-8x3/userlist.py
+++ b/Lib/dos-8x3/userlist.py
@@ -1,52 +1,66 @@
# A more or less complete user-defined wrapper around list objects
class UserList:
- def __init__(self, list = None):
- self.data = []
- if list is not None:
- if type(list) == type(self.data):
- self.data[:] = list
- else:
- self.data[:] = list.data[:]
- def __repr__(self): return repr(self.data)
- def __cmp__(self, list):
- if type(list) == type(self.data):
- return cmp(self.data, list)
- else:
- return cmp(self.data, list.data)
- def __len__(self): return len(self.data)
- def __getitem__(self, i): return self.data[i]
- def __setitem__(self, i, item): self.data[i] = item
- def __delitem__(self, i): del self.data[i]
- def __getslice__(self, i, j):
- userlist = self.__class__()
- userlist.data[:] = self.data[i:j]
- return userlist
- def __setslice__(self, i, j, list):
- if type(list) == type(self.data):
- self.data[i:j] = list
- else:
- self.data[i:j] = list.data
- def __delslice__(self, i, j): del self.data[i:j]
- def __add__(self, list):
- if type(list) == type(self.data):
- return self.__class__(self.data + list)
- else:
- return self.__class__(self.data + list.data)
- def __radd__(self, list):
- if type(list) == type(self.data):
- return self.__class__(list + self.data)
- else:
- return self.__class__(list.data + self.data)
- def __mul__(self, n):
- return self.__class__(self.data*n)
- __rmul__ = __mul__
- def append(self, item): self.data.append(item)
- def insert(self, i, item): self.data.insert(i, item)
- def pop(self, i=-1): return self.data.pop(i)
- def remove(self, item): self.data.remove(item)
- def count(self, item): return self.data.count(item)
- def index(self, item): return self.data.index(item)
- def reverse(self): self.data.reverse()
- def sort(self, *args): apply(self.data.sort, args)
- def extend(self, list): self.data.extend(list)
+ def __init__(self, list=None):
+ self.data = []
+ if list is not None:
+ if type(list) == type(self.data):
+ self.data[:] = list
+ else:
+ self.data[:] = list.data[:]
+ def __repr__(self): return repr(self.data)
+ def __cmp__(self, other):
+ if isinstance(other, UserList):
+ return cmp(self.data, other.data)
+ else:
+ return cmp(self.data, other)
+ def __len__(self): return len(self.data)
+ def __getitem__(self, i): return self.data[i]
+ def __setitem__(self, i, item): self.data[i] = item
+ def __delitem__(self, i): del self.data[i]
+ def __getslice__(self, i, j):
+ i = max(i, 0); j = max(j, 0)
+ userlist = self.__class__()
+ userlist.data[:] = self.data[i:j]
+ return userlist
+ def __setslice__(self, i, j, other):
+ i = max(i, 0); j = max(j, 0)
+ if isinstance(other, UserList):
+ self.data[i:j] = other.data
+ elif isinstance(other, type(self.data)):
+ self.data[i:j] = other
+ else:
+ self.data[i:j] = list(other)
+ def __delslice__(self, i, j):
+ i = max(i, 0); j = max(j, 0)
+ del self.data[i:j]
+ def __add__(self, other):
+ if isinstance(other, UserList):
+ return self.__class__(self.data + other.data)
+ elif isinstance(other, type(self.data)):
+ return self.__class__(self.data + other)
+ else:
+ return self.__class__(self.data + list(other))
+ def __radd__(self, other):
+ if isinstance(other, UserList):
+ return self.__class__(other.data + self.data)
+ elif isinstance(other, type(self.data)):
+ return self.__class__(other + self.data)
+ else:
+ return self.__class__(list(other) + self.data)
+ def __mul__(self, n):
+ return self.__class__(self.data*n)
+ __rmul__ = __mul__
+ def append(self, item): self.data.append(item)
+ def insert(self, i, item): self.data.insert(i, item)
+ def pop(self, i=-1): return self.data.pop(i)
+ def remove(self, item): self.data.remove(item)
+ def count(self, item): return self.data.count(item)
+ def index(self, item): return self.data.index(item)
+ def reverse(self): self.data.reverse()
+ def sort(self, *args): apply(self.data.sort, args)
+ def extend(self, other):
+ if isinstance(other, UserList):
+ self.data.extend(other.data)
+ else:
+ self.data.extend(other)