On 2016-07-04 17:48, Marco Buttu wrote: > Hi all, > > if I open a file in text mode, do you know why file.seek() returns the > number of bytes, and file.tell() takes the number of bytes? I was > expecting the number of characters, like write() does:
Your expectations are not correct. tell() and seek() of a file in binary mode return the current position of the file descriptor. For a file in text mode, tell() and seek() use a opaque number [1]. The number reflects the internal state of the text IO object. You can't draw any conclusion from it. You are only allowed to seek to offsets which you have acquired by tell(), too. [1] https://docs.python.org/3/library/io.html#io.TextIOBase.tell -- https://mail.python.org/mailman/listinfo/python-list