Reputation: 181
Normally, I would do something like:
f=open(path)
for line in iter(f.readline, ''):
print f.tell()
However, seek operations are not possible with:
import sys
for line in iter(sys.stdin.readline, ''):
print sys.stdin.tell()
Upvotes: 0
Views: 513
Reputation: 636
You can calculate file offset yourself.
import sys
offset = 0
for line in sys.stdin:
print offset
offset += len(line)
Upvotes: 1