[Tutor] pickle problems

eryksun eryksun at gmail.com
Sun Aug 12 15:06:51 CEST 2012


On Sun, Aug 12, 2012 at 7:44 AM, Richard D. Moores <rdmoores at gmail.com> wrote:
>
> I just discovered
> os.path.getsize('factors.txt')
> and that factors.txt has a size of 2 bytes when "empty".
> (I changed the file extension to .txt so I could delete the contents.)

No, an empty file has no data; the size is 0. You must have saved a
text file in Windows that added a byte order mark (BOM). Windows adds
a BOM for UTF-8 and UTF-16 ('Unicode') files. It sounds silly to have
a BOM for UTF-8, which can't have a little endian or big endian byte
order, but it's there to distinguish UTF-8 from 8-bit ANSI (e.g.
Windows 1252).


More information about the Tutor mailing list