Does f.seek(500000,0) go through all the first 499999 characters of the file before getting to the 500000th?
In other words, is f.seek(n,0) of order O(n) or O(1)?
It would depend on the implementation of f.  However, in normal file-system files, it is O(1).
If python implements f on text files, it could be implemented as O(n), as each character may need to be inspected to manage cr/lf pairs correctly.

This would be based on whether f.seek(n,0) gave the same result as a loop of reading chars, and (depending on OS) cr/lf were shrunk to lf or lf expanded to cr/lf 

If python implements f on a compressed stream,  then the order would b O(n), as decompression may require some working of blocks, and decompression.
Complexity of f.seek() in Python