modify element of a list.

KraftDiner bobrien18 at yahoo.com
Thu Aug 17 11:35:41 EDT 2006


Hi I have a list of Ojbects... I want to change one of the objects in
the list for a new object....
How do I replace an existing object with a new one and maintain the
list order..

This is what I have...

def setAttribute(self, desc, value):
   n = anObject(desc, value)
   for o in self.Objects:
      if o.getDescription() == desc:
         self.Objects.replace(o, n) #Replace o with n?
         return
   self.Objects.append(n)

It's the replace in place that I don't know how to do...




More information about the Python-list mailing list