On 2014-02-12 14:35, Ian Kelly wrote: > You can't write lists directly to files. You can only write strings > to files. To write and read a list, you'll need to first serialize > it and later deserialize it.
To be pedantic, you can only write *bytes* to files, so you need to serialize your lists (or other objects) to strings and then encode those to bytes; or skip the string and encode your list/object directly to bytes. Though unfortunately, I now have a tweaked version of that late-night commercial¹: "PICKLE: SERIALIZE DIRECTLY TO BYTES! PICKLE: SERIALIZE DIRECTLY TO BYTES! PICKLE: SERIALIZE DIRECTLY TO BYTES!" -tkc ¹ http://www.youtube.com/watch?v=f_SwD7RveNE -- https://mail.python.org/mailman/listinfo/python-list