[Python-checkins] CVS: python/dist/src/Lib UserList.py,1.8,1.9

Jeremy Hylton python-dev@python.org
Thu, 30 Mar 2000 19:17:45 -0500


Update of /projects/cvsroot/python/dist/src/Lib
In directory goon.cnri.reston.va.us:/home/jhylton/python/src/Lib

Modified Files:
	UserList.py 
Log Message:
robustify UserList constructor -- will now accept any sequence
add test cases for non-UserList class, tuple, & string



Index: UserList.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/UserList.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** UserList.py	2000/02/02 15:10:14	1.8
--- UserList.py	2000/03/31 00:17:42	1.9
***************
*** 2,12 ****
  
  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, other):
--- 2,15 ----
  
  class UserList:
!     def __init__(self, initlist=None):
          self.data = []
!         if initlist is not None:
!             # XXX should this accept an arbitary sequence?
!             if type(initlist) == type(self.data):
!                 self.data[:] = initlist
!             elif isinstance(initlist, UserList):
!                 self.data[:] = initlist.data[:]
              else:
!                 self.data = list(initlist)
      def __repr__(self): return repr(self.data)
      def __cmp__(self, other):