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:

>>> f = open('myfile', 'w')
>>> f.write('aè')
2

It seems to me not consistent, and maybe could also be error prone:

>>> f.seek(2)
2
>>> f.write('c')
1
>>> f.close()
>>> open('myfile').read()
   ...
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3...


--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to