Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'string': 0.09; 'bytes.': 0.09; 'encode': 0.09; 'objects)': 0.09; '-tkc': 0.16; 'bytes;': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'later': 0.20; 'skip': 0.24; '(or': 0.24; 'header:In-Reply-To:1': 0.27; 'lists': 0.32; "can't": 0.35; 'version': 0.36; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'read': 0.60; 'ian': 0.60; 'first': 0.61; "you'll": 0.62; 'url:v': 0.71; 'url:youtube': 0.71; 'url:watch': 0.77; 'received:50.22': 0.84 Date: Wed, 12 Feb 2014 16:14:27 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Wait... WHAT? In-Reply-To: References: <6c76ef4e-8c7c-4199-b30d-c4d55c1061c8@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392243237 news.xs4all.nl 2862 [2001:888:2000:d::a6]:60972 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66106 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.=20 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=C2=B9: "PICKLE: SERIALIZE DIRECTLY TO BYTES! PICKLE: SERIALIZE DIRECTLY TO BYTES! PICKLE: SERIALIZE DIRECTLY TO BYTES!" -tkc =C2=B9 http://www.youtube.com/watch?v=3Df_SwD7RveNE