The PyQGIS API for working with geometry collections has been improved:
del collection[1]
(deletes the second geometry from the collection). Also supports negative indices to count from the end of the collection.Additionally, you can now easily iterate over the geometries in the collection, allowing this type of code:
gc = QgsGeometryCollection()
gc.fromWkt('GeometryCollection( Point(1 2), Point(11 12), LineString(33 34, 44 45))')
for part in gc:
print(part.asWkt())