Fix Python generator