> Why not just use: for idx in range(options.from_id, options.to_id + 1)?
It would be better to use range(options.from_id, options.to_id + 1). 
(I did not know the functionality of range. )