]> granicus.if.org Git - python/commitdiff
__getslice__(): Make this use the constructor form that gets a sequence
authorFred Drake <fdrake@acm.org>
Fri, 6 Oct 2000 19:26:01 +0000 (19:26 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 6 Oct 2000 19:26:01 +0000 (19:26 +0000)
                 as a parameter; this was the only use of the base
                 constructor or surgical alteration of another object's
                 data attribute.

This change simplifies the constructor requirements for subclasses.

This relates to SourceForge bug #115928.

Lib/UserList.py

index aab511915ccc2a707b84fd09d39ecef9531a6e4c..e79faea1a1b440b72c36fd3545058ce8d3abcfbe 100644 (file)
@@ -24,9 +24,7 @@ class UserList:
     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
+        return self.__class__(self.data[i:j])
     def __setslice__(self, i, j, other):
         i = max(i, 0); j = max(j, 0)
         if isinstance(other, UserList):