On 22 Dec 2005 10:14:10 -0800, KraftDiner <[EMAIL PROTECTED]> wrote:
Is there a cleaner way to implement this code?

                        if len(self.listOfObjects) == 0:
                                self.listOfObjects.append(self.currentObject)
                        elif:
                                self.listOfObjects[self.currentSlice] = self.currentObject

listOfObjects is a list of lists....
If the listOfObjects is [] then I have to use append to add the first
list
otherwise I can access each list using the index into the list.

I'm assuming from your code that self.listOfObjects always exists (even if it is empty) and that self.currentObject is also  list.

   if  (not self.listOfObjects) or (self.listOfObjects[self.currentSlice] = self.currentObject):
                self.listOfObjects =  self.currentObject

If self.currentObject is not a list or is only sometimes a list then change the 2nd line to

               self.listOfObjects =  list( self.currentObject )

HTH :)
--

Tim Williams
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to