I am using Python 3.3.0, on windows 64bit.
I have a text file as shown below: (see bottom for download link at mediafire)
hello-data1:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah-data2:blah blah blah blah blah blah blah blah blah blah blah-data3: Empty-data4: EmptyI'm trying to navigate around the file, and thus I use .tell() to figure out what my position is. However, when reading through the lines of the file as shown below, I get a very strange result:
f=open("test.txt")while True: a = f.readline() print("{} {}".format(repr(a),f.tell())) if a == "": breakThe result:
'hello\n' 7'\n' 9'-data1:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n' 18446744073709551714'\n' 99'\n' 101'-data2:blah blah blah blah blah blah blah blah blah blah blah\n' 164'-data3: Empty\n' 179'\n' 181'-data4: Empty' 194'' 194What's with the 18446744073709551714 for the 3rd line? Though it looks like an impossible value, f.seek(18446744073709551714) is an acceptable value that apparently does bring me to the end of the 3rd line. Though, I can't seem to figure out why.
EDIT:Opening in binary mode gives no problems with tell():
f=open("test.txt","rb")while True: a = f.readline() print("{} {}".format(repr(a),f.tell())) if a == b"": breakThe result:
b'hello\r\n' 7b'\r\n' 9b'-data1:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\r\n' 97b'\r\n' 99b'\r\n' 101b'-data2:blah blah blah blah blah blah blah blah blah blah blah\r\n' 164b'-data3: Empty\r\n' 179b'\r\n' 181b'-data4: Empty' 194b'' 194The test.txt text file is downloadable here, just a tiny 194 bytes: http://www.mediafire.com/?1wm4lujb2j48y23