You might like this as:   for i, task in enumerate(self.task_xml):